Repository navigation
Events: write the same HTML on a render cache hit as on a fresh render - #871
Merged
Merged
Conversation
A render cache replay of a component with Events gave its root element a data-cid="<render id>" attribute, which a fresh render does not write. Citry's browser code finds an Events instance through the render ID in the manifest the server sends with the page, never through that attribute, so the replay now writes none. The fresh-render branch that would have written it ran only when direct_prepared_render_active() was False, and every render sets it to True (render_impl and render_prepared_direct both enter typed_render_scope(direct=True)), so it is removed too. Comments that described a fixed data-cid marker are updated. Closes #659 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
JuroOravec
added a commit
that referenced
this pull request
Nov 24, 2026
#871 (#878) Records the Mechanism 7 security reviews of six merged Events changes, in the form docs/security/reviews/README.md describes. Each record is built from the pull request description, the merged diff and its tests; where a description does not record something the template asks for, the record says so. Co-authored-by: Claude Sonnet 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
(Opus 5.5)
What was wrong
When the render cache served a component with Events, the root element
got
data-cid="<render id>". A fresh render of the same component doesnot write that attribute. So the cached HTML differed from the fresh
HTML, and the component's compiled browser template differed too (its
citryAttrsheld the extra attribute). A page that mixed fresh andcached copies of one component loaded two templates for it.
Which output is correct
The fresh render's. Citry's browser code never reads a fixed-name
data-cid:_vue/client.js,dev_checks.jsandpackages/js/citry-clientdo not mention it. The client finds an Eventsinstance by
occurrence.renderIdin the manifest the server sends withthe page (
client.jsaround 3770-3814). The per-renderdata-cid-<id>markers are a different attribute and are unchanged.
What this changes
ext/events/cache.py: replay stages no root marker for an Eventsinstance. Its manifest entry, with the fresh render ID, is unchanged.
ext/events/emission.py: removes the branch that wrotedata-cidwhendirect_prepared_render_active()was False. Every render enterstyped_render_scope(direct=True), so the branch never ran. I checkedthis by making the branch log each run: the whole non-e2e suite
(15834 tests) never reached it.
data-cidmarker (attrs.py,serialize.py) are updated. The name stays reserved forc-bindandCitry UI attributes, and
serialize.pystill drops a valueddata-cid="marker insecurity_javascriptomit and forbid modes asa guard, though no first-party code writes one now.
docs/design/caching.mdsection 8.2 says that replay writes the sameHTML as a fresh render, apart from new State tokens.
CHANGELOG.md: a Fixes entry under v1.3.0.Older design docs (
events.mdsection 5.5,events_plan.md,dependencies.md) describe the Alpine-era fixeddata-cid. They werealready out of date before this change and are left as they are.
Tests
test_cache_replay_of_an_events_component_writes_the_live_html(component cache and
<c-cache>fragment): with the same render IDsand Vue app ID, the replayed serialized page equals the fresh one byte
for byte. The test also checks that the component built only once.
Both cases fail without the change.
data-cidmarker nowcheck the staged entry's render ID instead (they prove the stored
State token was accepted).
fresh render with a replay for Events with signed, server-stored and
Pydantic State,
css_data,js_data,$c-trbindings, nested andmulti-root components, shared roots, slot fills,
<c-element>andsecurity_javascript="omit". All outputs are equal after the change,apart from the newly signed State tokens. All differ before it.
tests/e2e/test_cache_replay_e2e.pyandtest_vue_events_default_e2e.py(79 tests) pass in Chromium. Thereplay tests click cached Events components, which now have no
data-cid.packages/py/citry: 15870 passed.ruff,ruff format --check,mypy(host and--platform linux) andscripts/validate.pypass.Review
An independent reviewer checked correctness, the reachability claim, the
sweep, the tests, versioning and the prose. It also ran a security pass
for markers for Citry's browser code (Mechanism 7) and a check against
the advisory survey (Mechanism 8). It found no hole. Data cannot write a
data-cidthat Citry's browser code trusts, because no browser codereads it, and
c-bindand Citry UI still refuse the name. Its prose anddoc findings are folded in.
Versioning
An entry written by citry 1.2.0 replays under this code without the
attribute. 1.3.0 starts with an empty cache anyway, because
_RENDER_CONTRACTincludes the Citry version.and
data-cidstays reserved. This is a fix, so it fits 1.3.0.Closes #659
🤖 Generated with Claude Code