Skip to content

Make managed server port allocation atomic - #204

Merged
ccomb merged 1 commit into
mainfrom
fix/atomic-managed-server-port
Jul 14, 2026
Merged

Make managed server port allocation atomic#204
ccomb merged 1 commit into
mainfrom
fix/atomic-managed-server-port

Conversation

@ccomb

@ccomb ccomb commented Jul 14, 2026

Copy link
Copy Markdown
Owner

Summary

  • let VoLCA reserve an OS-assigned loopback port with Warp's openFreePort
  • announce the actual port only after the listening socket is bound
  • add Server(port="auto") to pyvolca while preserving existing port=0 semantics
  • cover dynamic-port parsing, invalid announcements, command construction, and compatibility

Why

The canonical converter previously probed and released a free port before starting VoLCA. Another local process could claim that port and impersonate the engine. This change removes the TOCTOU at its source.

Verification

  • pyvolca: 231 passed, 7 skipped
  • pyright: 0 errors, 0 warnings
  • Warp openFreePort / runSettingsSocket integration type-checked locally
  • full native build is delegated to CI because this checkout has GHC 9.6.7 while the repository requires GHC 9.12.4

@ccomb
ccomb merged commit 721973d into main Jul 14, 2026
11 checks passed
@ccomb
ccomb deleted the fix/atomic-managed-server-port branch July 14, 2026 01:19
ccomb added a commit that referenced this pull request Jul 14, 2026
## Summary
Follow-up to the post-merge review of #204.

- `_await_bound_port` now lets the reader thread do the parsing and
relies on `thread.join(timeout)`: the engine's death closes stdout and
ends the thread, so the queue, the manual deadline loop and the
`process.poll()` check were three error paths for the same condition.
Same guarantees, a third less code.
- A non-numeric `VOLCA_PORT=` value now raises the same clear
`RuntimeError` as an out-of-range one, instead of leaking a bare
`ValueError`. Covered by a new test parameter.
- The `--port` help text and the changelog now say that port 0 binds the
loopback interface only — Warp's `openFreePort` binds 127.0.0.1, unlike
the fixed-port path which listens on all interfaces. Without this note
the narrower bind is a silent behavior difference.

## Verification
- pyvolca: 233 passed, 7 skipped
- pyright on `server.py`: 0 errors, 0 warnings
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.

1 participant