osrlib.crawl.views
The projection API: the player's safe whitelist and the referee's full state.
execute() mutates session state; build_player_view
and build_referee_view build these frozen
projections from that state alone, never from the event log.
The player view is an enumerated whitelist: party public sheets, location and facing, explored cells with their edges (secret doors only if discovered — an undiscovered secret door renders as wall), known piles and emptied caches in explored space, active effects on party members with remaining durations, the elapsed clock, the mode, the current encounter/battle public state (names, counts, distances, visible conditions — never HP), fatigue/exhaustion/deprivation status, and the adventure's public prose. It never carries unexplored geometry, undiscovered traps or secret doors, monster HP or stat internals, referee-visibility roll outcomes, session flags, RNG state, or the seed — the seed lives only in the save, and neither view carries it.
The referee view carries everything else the save does, minus RNG internals and the seed, for LLM referees and tests. A front end must never trust the client: a networked game keeps the session and the referee view server-side, and returns only the player view — or player-visibility events — over the wire.
EdgeView
EncounterGroupView
Bases: BaseModel
A monster group as the players see it: id, name, count, distance, behavior — never HP.
The group id is the command vocabulary: battle declarations name their
target_group_id with it, so the projection must carry it for a wire client
to fight at all — an allocator ordinal, not a secret (the id doctrine
MemberView already sets).
EncounterView
ExploredLevelView
MemberEffectView
MemberView
PileView
PlayerView
Bases: BaseModel
The safe projection: an enumerated whitelist of exactly the fields a player may see.
RefereeView
build_player_view
build_player_view(session) -> PlayerView
Build the player view from session state (never from the event log).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
session
|
GameSession
|
The running session. |
required |
Returns:
| Type | Description |
|---|---|
PlayerView
|
The frozen whitelist projection. |
build_referee_view
build_referee_view(session) -> RefereeView
Build the referee view: everything but RNG internals and the seed.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
session
|
GameSession
|
The running session. |
required |
Returns:
| Type | Description |
|---|---|
RefereeView
|
The full-state projection. |