evals / document-preview
extract-render-session
Expected
Hidden from the reviewer, like the grading note below.
- preview-state
- holds
- render-sessions
- holds
This is a sound extraction. refresh captures the operation's generation before any await and passes that same generation into _render_session. The helper's publication and busy cleanup use it, so old refreshes cannot replace the page or clear a newer request's busy indication. Consider a new refresh starting during catalog.resolve or renderer.open, as well as one starting during render or close. All are preserved. The acquired session is still closed exactly once before completion after a successful render, render failure, or cancellation during render. Close failure still reaches the caller and the current busy indication is cleared. Early catalog/open failure uses the caller's original generation. The existing retention of a prior page during loading is preserved. Do not report the extraction or continued old work itself as a defect. Do not require new public tests, automatic cancellation of superseded requests, a different framework, or unsupported thread safety. Assess both contracts and penalize unsupported findings, including false cleanup or failure-propagation findings.
Change
53 unmodified lines545556575859606162636453 unmodified lines self.state.busy = False raise
await self._render_session(session, generation)
async def _render_session( self, session: RenderSession, generation: int ) -> None: 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.