Skip to content

Docstrings: crawl hooks and views - #98

Merged
mmacy merged 2 commits into
mainfrom
docs/api-ref-crawl-hooks
Sep 14, 2026
Merged

Docstrings: crawl hooks and views#98
mmacy merged 2 commits into
mainfrom
docs/api-ref-crawl-hooks

Conversation

@mmacy

@mmacy mmacy commented Sep 14, 2026

Copy link
Copy Markdown
Owner

I rewrote the docstrings for the authored hooks (gates, triggers, quests, narrative), the interpreter that plays them, and the view projections, so a developer reading the published reference can wire an adventure and render a front end without opening the source. Each module docstring now opens with placement: which authoring model holds the thing, which part of the session evaluates it, and which events report the result. Every pydantic field in the six files has a PEP 224 attribute docstring, so the field rows render with prose instead of bare names, which also makes MemberView.id and its siblings resolvable targets for the command docstrings that send readers to the view for ids. The new examples run under the docs harness: the interpreter's builds a session with a trigger, registers the listener, and shows the flag, the fired-mark, and the journal entry the firing produced; build_player_view and build_referee_view each build a session and show what the two projections do and do not contain.

I corrected two claims in the interpreter that disagreed with the code. The class docstring said "matching stops below depth five" (src/osrlib/crawl/interpreter.py:287 before the change); matching does not stop, since handle runs _would_fire and _advance evaluates every clause past the bound, and what stops is issuing. The _MAX_MATCH_DEPTH docstring had the same error and now says it is the deepest events a firing or a quest advancement still acts on (src/osrlib/crawl/interpreter.py:60).

The only no-run block is the one-line registration fragment in the Interpreter class docstring, which names a session built elsewhere; its runnable twin is the full example in the same docstring. I left nothing undocumented on purpose. I found no code defects.

uv run ruff format --check && uv run ruff check && uv run pyright && uv run pytest -q && uv run mkdocs build --strict passes: 2273 passed, 73 skipped, pyright clean, strict build clean.

https://claude.ai/code/session_01GL26QnA6dCrvUc3WmhzFSa

Rewrite the docstrings of gates, triggers, quests, narrative, the
interpreter, and views for a developer reading the published reference.
Each module docstring now opens with where the thing sits: the authoring
model that holds it, the part of the session that evaluates it, and the
events that report the result. Every pydantic field gets a PEP 224
attribute docstring so the reference renders prose instead of a bare
name, and the runnable examples were all run against the code.

Correct two claims in the interpreter that disagreed with the code: the
cascade bound suppresses issuing, not matching, and the walk keeps
evaluating clauses past the bound.

Claude-Session: https://claude.ai/code/session_01GL26QnA6dCrvUc3WmhzFSa
The views module docstring said neither builder reads the event log; the
referee view is the save's serialization and includes it, so the sentence
now separates the two. The player-view exclusion list gains the quests
that are not active, since the projection keeps only active ones.
RefereeView.state now links the function that names every save key.

The interpreter docstring now says that past the cascade bound a quest
the event would have activated records one note and stops, so its
objective clauses are not evaluated, and that a quest walk returns at the
completion it issues, leaving a second objective that matched the same
event for the next event. QuestSpec.completion says the same for the
author. NarrativeBlock.guidance now says osrlib reads it nowhere and a
narrator takes it from the authored document.

Claude-Session: https://claude.ai/code/session_01GL26QnA6dCrvUc3WmhzFSa
@mmacy
mmacy merged commit 59f2684 into main Sep 14, 2026
5 checks passed
@mmacy
mmacy deleted the docs/api-ref-crawl-hooks branch September 14, 2026 06:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant