Skip to content

Give the referee view a typed model instead of a raw dict #105

Description

@mmacy

PlayerView is a typed pydantic model. RefereeView.state is dict, the raw save payload from session_state. The view that carries the most information has the least structure, and the front ends that need it most (osr-editor and osr-web's referee side) read state["dungeon_state"]["..."] by hand.

The reviewer of #97, working from the Adventure, DungeonSpec, and LevelSpec docstrings alone, got a session running and moving in one attempt and then took five attempts to read the party's position back through the referee view. That is the largest single point of friction a new front-end author hits.

Proposal: a typed RefereeView whose fields are the same groups the save serializes (party, location, dungeon state, encounter and battle state, ledger, clock, flags, journal, quests, event log), built from the session's own models rather than from a model_dump. Keep session_state for persistence. The docstrings in crawl/views.py and crawl/session.py say what the referee view contains today; the acceptance test is that every key the docstring names is a typed field. This is a schema decision for schema_version of the view if the view is serialized anywhere; check osr-web before choosing.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions