Skip to content

docs(events): document every State setting, and make the Events and State pages easier to skim #852

Done

Description

@JuroOravec

(Opus 5.5)

Maintainer review of the Events docs (2026-11-24), after a Reddit reader asked how long signed State tokens live and how _max_age changes that. The answer is spread across several pages, and the two main Events pages are harder to skim than they should be. This issue collects the maintainer's requests for one docs pull request.

Follow docs/best-practices/writing-docs.md and the House style in CLAUDE.md. Old heading anchors do not need to keep working: rename freely. Update every link to a renamed anchor across docs_site/content/.

1. Document every State setting properly

State has five settings (STATE_META_NAMES in packages/py/citry/citry/ext/events/state.py): _public, _model, _storage, _max_bytes and _max_age. None of them has a clear reference section. _max_age is explained only briefly in "Choose where data lives" on Event state (docs_site/content/events/state.md, the table around line 181), plus the 1.0.0 upgrade guide, which doesn't count as reference. _max_bytes is mentioned once on that page. _public and _model share one section, and _storage is explained only through the "Choose where data lives" table.

Add a section on the State page that covers each setting the same way: what it does, its default, the values it accepts, what happens on an invalid value, and a short code example. A table of all five settings at the top of the section helps readers find the one they need. Facts to confirm against the source: the State docstring in component.py around line 870, and the validation in ext/events/state.py (around line 1042 for _max_age).

For _max_age in particular, which a Reddit reader asked about:

  • The default is 24 hours, for signed State and for _storage = "server" (where it becomes the cache entry's time-to-live).
  • It takes a datetime.timedelta of at least one second. Anything else is rejected when the component class is checked. None means the 24-hour default, so a token always expires.
  • The clock restarts on every server event, because each call returns a fresh token. The lifetime counts from the last token Citry issued, not from the first page load.
  • An expired token fails the call with stale_state. Link Handle out-of-date pages and why tokens expire.

Sources for _max_age: ext/events/tokens.py (module docstring, _STATE_DEFAULT_MAX_AGE, _effective_max_age). docs_site/content/about/versioning.md ("State token lifetime") and other pages that explain a setting should link the new section instead of repeating it.

1b. Give the settings API reference entries

The API reference has no entry for any of the five settings. The only place is one dense paragraph in the Component.State docstring (component.py around line 857), rendered on Component. Yet these names are covered by the 1.x promise: citry/__init__.py (around line 16) says the _ configuration names the docs teach, such as _max_age on State and _guard on Events, are public. The reference is built from docstrings with griffe, which skips _ names, so they need a deliberate place:

  • Give each setting its own entry the reference can link to, for example an Attributes: section in the Component.State docstring (one item per setting: type, default, meaning), or a hand-written reference section if griffe can't render that well.
  • The guide section from part 1 and the reference entries link to each other. The guide explains when and why to use each setting; the reference lists type, default and accepted values.
  • Check Events the same way: _guard, _context and any other _ settings the docs teach should get the same treatment, or be named as a follow-up.

2. Server events (docs_site/content/events/index.md), "Set a signing secret"

  • The Django paragraph (around line 92, citry.contrib.django.secret() and SECRET_KEY_FALLBACKS) interrupts the main flow. Make it a subsection or an admonition.
  • Rotating a secret ("To rotate a secret of your own...", around line 98) gets its own subsection.
  • "When old and new workers run at the same time during a deploy..." (around line 112) is too dense. Make it skimmable and shorter, for example as numbered steps.

3. Event state (docs_site/content/events/state.md)

  • "A handler receives them through its state parameter, and any change it makes is kept for the next call." Follow it with a short code example of a handler reading and changing State.

  • "Keep State small: ids, filters, page numbers, flags such as "editing"..." (around line 33): make it a subsection or an admonition.

  • The code block after "Instead, keep the id in State, load the record for the current user, and pass every input explicitly:" (around line 81): right after def refresh(self, state, request):, read the State values on their own lines, optionally with a comment:

    def refresh(self, state, request):
        # Access state data
        project_id = state.project_id
        show_archived = state.show_archived

    Then use the local names in the rest of the handler.

  • :c-<field> on inputs (around line 100): move it further down the page, and give it a clearer heading such as ":c-<field> binds state to inputs" (or a shorter form within the heading rule).

  • Reconsider every section heading on both pages, keeping the rule of about four words and 24 characters. For example, "Pass every input" doesn't tell the reader what the section is about; "Access state in handlers" gives a clear direction.

4. Record the heading lesson as a writing rule

Add the "Pass every input" versus "Access state in handlers" example to docs/best-practices/writing-docs.md, section "Write short headings" (around line 96), or to CLAUDE.md's House style if it fits better there: a heading that states an instruction without naming its subject is too vague. A heading should name the thing the section helps with.

Done when

  • Every State setting has one clear guide section and an API reference entry, and other pages link to them.
  • The changes above are made, and every renamed anchor is updated wherever it is linked.
  • The docs build passes, and the heading guard reports no new heading over 24 characters (or each one has a reason).
  • The docs-cold-reader agent has read both pages and its findings are addressed.

Activity

  1. added
    documentation
    on Nov 24, 2026
  2. changed the title [-]docs(events): document State _max_age, and make the Events and State pages easier to skim[/-] [+]docs(events): document every State setting, and make the Events and State pages easier to skim[/+] on Nov 24, 2026
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

    documentation

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions