evals / document-preview
extract-render-session-local-generation
Expected
Hidden from the reviewer, like the grading note below.
- preview-state
- violation
- render-sessions
- holds
The extracted _render_session captures self._generation on helper entry instead of receiving refresh's captured generation. Its caller already awaited catalog.resolve and renderer.open. An older refresh that resumes after a new refresh starts adopts the new generation. Its old page can then replace the current page, and its finally block can clear busy while the newer refresh is still rendering. These are two consequences of one ownership regression, not unrelated defects. A concrete interleaving with the old open pending makes the evidence checkable. The same regression also lets an old refresh overwrite a newer page after the newer request has fully completed. The outer generation check only handles catalog/open failures and does not protect the extracted normal path. Find the ownership loss where the helper rereads the current generation or where the original generation is omitted at its call. Restoring the original operation generation through the nested helper repairs both state mutations. Cleanup and error propagation remain sound: each acquired session closes exactly once, render/cancel/close failures propagate, and current busy cleanup runs even when close fails. Keep render-sessions expected clean. Existing state retention while loading, no automatic superseding cancellation, and the single event-loop scope are unchanged. Do not invent resource leaks or missing baseline infrastructure. Useful uncertainty earns partial credit only when it correctly identifies the evidence gap; the supplied complete code supports a definite ownership finding here.
Change
53 unmodified lines5455565758596061626353 unmodified lines self.state.busy = False raise
await self._render_session(session)
async def _render_session(self, session: RenderSession) -> None: generation = self._generation try: page = await session.render() if generation == self._generation:Contracts
preview-state
---
name: preview-state
message: Let the latest requested document own the visible preview state.
---
## Rules
Keep the last displayed page visible while a refresh is pending. Only the latest refresh may replace that page
or finish the busy indication. Work from earlier refreshes may complete but must leave the current refresh's
state alone. These requirements apply when loading, rendering, and closing sessions overlap.
## Checks
Trace `PreviewController.refresh` through its awaited operations. Consider overlapping refreshes and a failure
while another refresh is pending. Check the displayed page and busy indication through completion.
render-sessions
---
name: render-sessions
message: Release each acquired render session and preserve failures for the caller.
---
## Rules
Each successful `Renderer.open` transfers one session to its refresh. Call and await that session's `close`
exactly once before the refresh returns, including when rendering fails or the caller cancels the render.
Finish the current refresh's busy indication even if closing raises. Propagate failures to the caller.
An open that raises has not transferred a session. Repeated cancellation during cleanup is outside this API's
guarantee. Starting a newer refresh does not cancel existing work.
## Checks
Follow acquisition, rendering, and cleanup in `preview.py`. Check rendering failure, cancellation during rendering,
and a close failure. Confirm that a session remains owned by the refresh that acquired it.