Skip to content

Add cooperative live-session Stop and reliable port reuse - #34

Merged
marpaia merged 10 commits into
masterfrom
marpaia/17
Sep 25, 2026
Merged

marpaia merged 10 commits into
masterfrom
marpaia/17

Conversation

@marpaia

@marpaia marpaia commented Sep 24, 2026 •

Copy link
Copy Markdown
Collaborator

Stop session now closes a live simulation after the current individual step or atomic checkpoint write, drains its worker, and releases the server port. The authenticated WebSocket reader accepts Stop while the same client has a long command running; queued work is rejected, and the browser retains a normal Stopped state. Closing a browser still pauses for reconnection.

Fix immediate-reconnect races by removing/pause-marking disconnected sockets before awaiting their worker, pruning closed connections before admitting replacements, and snapshotting frame broadcast recipients before asynchronous capture. A reconnect cannot inherit a stale playing frame.

Validation: 30 focused Python tests passed on macOS; 30 viewer tests plus typing/lint/build; real Chromium paused/playing/reconnect/checkpoint/SIGINT sessions and repeated same-port launches of different models.

Final Windows CPU validation passed at 4677491: 30 tests, including measured real TCP backpressure, normal healthy-client shutdown, worker cleanup and same-port restart after Stop and actual CTRL_C_EVENT. The workflow uses Windows Server 2025, PowerShell and Python 3.12. The controlled console test does not claim every interactive terminal/keyboard configuration.

Independent review reproduced shutdown waiting on a nonreading client's buffered output. The correction bounds initial frame delivery and the entire WebSocket close, including aiohttp's preceding drain, and aborts an unresponsive transport. Lifecycle delivery and closure run concurrently. Explicit task cancellation remains distinct from cancellation of aiohttp's shared drain waiter. A real paused-receiver regression proves more than 1 MB buffered output, complete cleanup and different-model port reuse; POSIX covers initial delivery and Windows covers sustained broadcasts. The correction and final fixture received independent re-review.

Stop is cooperative: a non-returning user callback still prevents completion. Stop does not automatically save a checkpoint. Protocol and user docs distinguish Pause, Reset, browser close, Stop and terminal interruption.

Closes #17.

Independent review is complete against the original acceptance criteria and intended review base. The review report records per-criterion evidence, both corrected campaign findings, exact tested heads, landing order and platform limits.

Merged into master in the approved campaign order: #26, #27, #28, #31, #34, #36, #29, #30, #33, #35, #37, #32. The final tree preserves the reviewed implementation and integration regressions. Prerequisites were integrated with merge commits, and the frozen review bases were retained.

Landing validation: 534 Python tests passed (57 environment-dependent skips), 115 viewer tests passed, Ruff lint, strict type checks, viewer build/format checks, and actual Chromium feature/integration checks passed. Pyright retains the existing native-extension source warning. A Windows-only documentation link-test encoding failure was reproduced and fixed with an explicit UTF-8 read; the corrected final PR heads passed Windows CLI/shutdown checks and CUDA compilation. NVIDIA runtime execution remains unverified.

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.

Add explicit live-session shutdown and reliable stop/restart behavior

1 participant