feat(tls): one Transport of TCP or TLS over TCP, upgradable in the middle #522

Merged
argus merged 4 commits from loop/115-tls-transport into main 2026-10-27 12:33:03 +00:00
Collaborator

Closes #115

What

  • Transport in std/tls: plain TCP or TLS over TCP behind receiveBuffer, sendBuffer, finish, remote, with plain, encrypted, isEncrypted, tls, and the middle upgrade: upgrade (client) and upgradeAccepting (server), with the semantics of TlsStream.connect / TlsStream.accept.
  • A second upgrade is refused (the transport goes on); a failed handshake leaves the transport unusable (isClosed()), because the stream holds half a handshake.
  • The transport buffers nothing; the caller must drain its own Reader before upgrading (STARTTLS injection, documented on the type).
  • std/http drops its private transport.trb and uses std/tls's Transport.

Tests and docs

  • tests/conformance/tls-transport.trb: plain exchange, STARTTLS-style upgrade on both ends with ALPN, second upgrade refused, wrong name -> isCertificateRejected() then isClosed(), Transport.encrypted.
  • docs/standard-library/tls.md (and the skill mirror), docs/design/FIRST-PARTY.md row 17.

Seed impact

None: no compiler, runtime or seed/ change. torb/postgres's Wire copy is outside this repo and stays until it moves onto Transport.

Not run locally

No torb binary in the authoring environment: nothing was compiled or formatted before CI; tier A on the forge is the first run.

Closes #115 ## What - `Transport` in `std/tls`: plain TCP or TLS over TCP behind `receiveBuffer`, `sendBuffer`, `finish`, `remote`, with `plain`, `encrypted`, `isEncrypted`, `tls`, and the middle upgrade: `upgrade` (client) and `upgradeAccepting` (server), with the semantics of `TlsStream.connect` / `TlsStream.accept`. - A second upgrade is refused (the transport goes on); a failed handshake leaves the transport unusable (`isClosed()`), because the stream holds half a handshake. - The transport buffers nothing; the caller must drain its own `Reader` before upgrading (STARTTLS injection, documented on the type). - `std/http` drops its private `transport.trb` and uses `std/tls`'s `Transport`. ## Tests and docs - `tests/conformance/tls-transport.trb`: plain exchange, STARTTLS-style upgrade on both ends with ALPN, second upgrade refused, wrong name -> `isCertificateRejected()` then `isClosed()`, `Transport.encrypted`. - `docs/standard-library/tls.md` (and the skill mirror), `docs/design/FIRST-PARTY.md` row 17. ## Seed impact None: no compiler, runtime or `seed/` change. `torb/postgres`'s `Wire` copy is outside this repo and stays until it moves onto `Transport`. ## Not run locally No torb binary in the authoring environment: nothing was compiled or formatted before CI; tier A on the forge is the first run.
Adds Transport to std/tls: plain/encrypted, receiveBuffer, sendBuffer, finish,
remote, upgrade and upgradeAccepting, tls() and isEncrypted().
Tests, the std/http move and docs follow.

Refs #115
Refs #115
Refs #115
refactor(http): use std/tls's Transport
Some checks failed
ci / commit messages (pull_request) Successful in 6s
ci / what the change touches (pull_request) Successful in 6s
ci / the VS Code extension (editors/vscode) (pull_request) Has been skipped
pdisc / pdisc (pull_request) Successful in 12s
ci / which runners exist (pull_request) Successful in 2s
ci / bootstrap and conformance (linux-arm64) (pull_request) Has been skipped
ci / bootstrap and conformance (windows-x64) (pull_request) Has been skipped
ci / bootstrap and conformance (macos-arm64) (pull_request) Has been skipped
ci / bootstrap (linux-x64) (pull_request) Successful in 2m41s
ci / tier B (linux-x64) (pull_request) Has been skipped
ci / cross-compiled on linux-x64 (windows-x64) (pull_request) Has been skipped
ci / cross-compiled on linux-x64 (linux-arm64) (pull_request) Has been skipped
ci / cross-compiled on linux-x64 (macos-arm64) (pull_request) Has been skipped
ci / tools/release-sync and tools/registry (linux-x64) (pull_request) Successful in 3m23s
ci / every host emits the same C (pull_request) Successful in 5m15s
ci / the playground (torb as WebAssembly) (pull_request) Failing after 2m49s
ci / gates (pull_request) Has been cancelled
ci / pack the seed (pull_request) Has been cancelled
ci / archives (pull_request) Has been cancelled
ci / tier A (linux-x64) (pull_request) Has been cancelled
9cc7e9da32
Refs #115
fix(tls): make the session of a Transport a var field
Some checks failed
ci / commit messages (pull_request) Successful in 5s
ci / what the change touches (pull_request) Successful in 5s
ci / the VS Code extension (editors/vscode) (pull_request) Has been skipped
pdisc / pdisc (pull_request) Successful in 11s
ci / which runners exist (pull_request) Successful in 1s
ci / bootstrap and conformance (windows-x64) (pull_request) Has been skipped
ci / bootstrap and conformance (linux-arm64) (pull_request) Has been skipped
ci / bootstrap and conformance (macos-arm64) (pull_request) Has been skipped
ci / bootstrap (linux-x64) (pull_request) Successful in 2m37s
ci / tier B (linux-x64) (pull_request) Has been skipped
ci / cross-compiled on linux-x64 (windows-x64) (pull_request) Has been skipped
ci / cross-compiled on linux-x64 (linux-arm64) (pull_request) Has been skipped
ci / cross-compiled on linux-x64 (macos-arm64) (pull_request) Has been skipped
ci / tools/release-sync and tools/registry (linux-x64) (pull_request) Successful in 3m26s
ci / every host emits the same C (pull_request) Successful in 5m9s
ci / the playground (torb as WebAssembly) (pull_request) Successful in 2m39s
ci / tier A (linux-x64) (pull_request) Failing after 28m42s
ci / gates (pull_request) Has been cancelled
ci / pack the seed (pull_request) Has been cancelled
ci / archives (pull_request) Has been cancelled
d630bd8e0c
The upgrade methods assign it, and a field is const unless declared var.
style(tls): format the Transport conformance test
Some checks failed
ci / commit messages (pull_request) Failing after 4s
ci / what the change touches (pull_request) Successful in 4s
pdisc / pdisc (pull_request) Successful in 10s
ci / which runners exist (pull_request) Successful in 1s
ci / bootstrap and conformance (windows-x64) (pull_request) Has been skipped
ci / bootstrap and conformance (linux-arm64) (pull_request) Has been skipped
ci / bootstrap and conformance (macos-arm64) (pull_request) Has been skipped
ci / bootstrap (linux-x64) (pull_request) Successful in 2m42s
ci / the VS Code extension (editors/vscode) (pull_request) Successful in 14s
ci / cross-compiled on linux-x64 (linux-arm64) (pull_request) Has been skipped
ci / cross-compiled on linux-x64 (windows-x64) (pull_request) Has been skipped
ci / cross-compiled on linux-x64 (macos-arm64) (pull_request) Has been skipped
ci / gates (pull_request) Has been cancelled
ci / tier A (linux-x64) (pull_request) Has been cancelled
ci / tier B (linux-x64) (pull_request) Has been cancelled
ci / tools/release-sync and tools/registry (linux-x64) (pull_request) Has been cancelled
ci / every host emits the same C (pull_request) Has been cancelled
ci / the playground (torb as WebAssembly) (pull_request) Has been cancelled
ci / pack the seed (pull_request) Has been cancelled
ci / archives (pull_request) Has been cancelled
ff60cab1b6
orion force-pushed loop/115-tls-transport from ff60cab1b6
Some checks failed
ci / commit messages (pull_request) Failing after 4s
ci / what the change touches (pull_request) Successful in 4s
pdisc / pdisc (pull_request) Successful in 10s
ci / which runners exist (pull_request) Successful in 1s
ci / bootstrap and conformance (windows-x64) (pull_request) Has been skipped
ci / bootstrap and conformance (linux-arm64) (pull_request) Has been skipped
ci / bootstrap and conformance (macos-arm64) (pull_request) Has been skipped
ci / bootstrap (linux-x64) (pull_request) Successful in 2m42s
ci / the VS Code extension (editors/vscode) (pull_request) Successful in 14s
ci / cross-compiled on linux-x64 (linux-arm64) (pull_request) Has been skipped
ci / cross-compiled on linux-x64 (windows-x64) (pull_request) Has been skipped
ci / cross-compiled on linux-x64 (macos-arm64) (pull_request) Has been skipped
ci / gates (pull_request) Has been cancelled
ci / tier A (linux-x64) (pull_request) Has been cancelled
ci / tier B (linux-x64) (pull_request) Has been cancelled
ci / tools/release-sync and tools/registry (linux-x64) (pull_request) Has been cancelled
ci / every host emits the same C (pull_request) Has been cancelled
ci / the playground (torb as WebAssembly) (pull_request) Has been cancelled
ci / pack the seed (pull_request) Has been cancelled
ci / archives (pull_request) Has been cancelled
to 2beb1bb50c
All checks were successful
ci / commit messages (pull_request) Successful in 4s
ci / what the change touches (pull_request) Successful in 4s
ci / the VS Code extension (editors/vscode) (pull_request) Has been skipped
pdisc / pdisc (pull_request) Successful in 10s
ci / which runners exist (pull_request) Successful in 0s
ci / bootstrap and conformance (windows-x64) (pull_request) Has been skipped
ci / bootstrap and conformance (linux-arm64) (pull_request) Has been skipped
ci / bootstrap and conformance (macos-arm64) (pull_request) Has been skipped
ci / bootstrap (linux-x64) (pull_request) Successful in 7m4s
ci / tier B (linux-x64) (pull_request) Has been skipped
ci / cross-compiled on linux-x64 (windows-x64) (pull_request) Has been skipped
ci / cross-compiled on linux-x64 (linux-arm64) (pull_request) Has been skipped
ci / cross-compiled on linux-x64 (macos-arm64) (pull_request) Has been skipped
ci / tools/release-sync and tools/registry (linux-x64) (pull_request) Successful in 2m45s
ci / every host emits the same C (pull_request) Successful in 5m12s
ci / the playground (torb as WebAssembly) (pull_request) Successful in 2m24s
ci / tier A (linux-x64) (pull_request) Successful in 27m14s
ci / pack the seed (pull_request) Successful in 10s
ci / archives (pull_request) Has been skipped
ci / gates (pull_request) Successful in 0s
2026-10-27 06:43:52 +00:00
Compare
Collaborator

Not mergeable on 2beb1bb: rebase onto main (da96427); no other blockers.

Not mergeable on 2beb1bb: rebase onto main (da96427); no other blockers.
orion force-pushed loop/115-tls-transport from 2beb1bb50c
All checks were successful
ci / commit messages (pull_request) Successful in 4s
ci / what the change touches (pull_request) Successful in 4s
ci / the VS Code extension (editors/vscode) (pull_request) Has been skipped
pdisc / pdisc (pull_request) Successful in 10s
ci / which runners exist (pull_request) Successful in 0s
ci / bootstrap and conformance (windows-x64) (pull_request) Has been skipped
ci / bootstrap and conformance (linux-arm64) (pull_request) Has been skipped
ci / bootstrap and conformance (macos-arm64) (pull_request) Has been skipped
ci / bootstrap (linux-x64) (pull_request) Successful in 7m4s
ci / tier B (linux-x64) (pull_request) Has been skipped
ci / cross-compiled on linux-x64 (windows-x64) (pull_request) Has been skipped
ci / cross-compiled on linux-x64 (linux-arm64) (pull_request) Has been skipped
ci / cross-compiled on linux-x64 (macos-arm64) (pull_request) Has been skipped
ci / tools/release-sync and tools/registry (linux-x64) (pull_request) Successful in 2m45s
ci / every host emits the same C (pull_request) Successful in 5m12s
ci / the playground (torb as WebAssembly) (pull_request) Successful in 2m24s
ci / tier A (linux-x64) (pull_request) Successful in 27m14s
ci / pack the seed (pull_request) Successful in 10s
ci / archives (pull_request) Has been skipped
ci / gates (pull_request) Successful in 0s
to aed0424374
Some checks failed
ci / every host emits the same C (pull_request) Successful in 5m30s
ci / the playground (torb as WebAssembly) (pull_request) Successful in 2m32s
ci / tier A (linux-x64) (pull_request) Successful in 28m6s
ci / pack the seed (pull_request) Successful in 10s
ci / archives (pull_request) Has been skipped
ci / gates (pull_request) Successful in 0s
images / cr.torb.dev/torbscript/registry (push) Has been skipped
images / cr.torb.dev/torbscript/release-sync (push) Has been skipped
images / cr.torb.dev/torbscript/site (push) Has been skipped
ci / commit messages (push) Successful in 5s
ci / what the change touches (push) Successful in 5s
pdisc / pdisc (push) Successful in 9s
ci / gates (push) Has been cancelled
ci / bootstrap (linux-x64) (push) Has been cancelled
ci / tier A (linux-x64) (push) Has been cancelled
ci / tier B (linux-x64) (push) Has been cancelled
ci / tools/release-sync and tools/registry (linux-x64) (push) Has been cancelled
ci / bootstrap and conformance (windows-x64) (push) Has been cancelled
ci / bootstrap and conformance (linux-arm64) (push) Has been cancelled
ci / bootstrap and conformance (macos-arm64) (push) Has been cancelled
ci / cross-compiled on linux-x64 (windows-x64) (push) Has been cancelled
ci / cross-compiled on linux-x64 (linux-arm64) (push) Has been cancelled
ci / cross-compiled on linux-x64 (macos-arm64) (push) Has been cancelled
ci / every host emits the same C (push) Has been cancelled
ci / the VS Code extension (editors/vscode) (push) Has been cancelled
ci / which runners exist (push) Successful in 1s
ci / the playground (torb as WebAssembly) (push) Has been cancelled
ci / pack the seed (push) Has been cancelled
ci / archives (push) Has been cancelled
images / cr.torb.dev/torbscript/site:edge (main) (push) Has been cancelled
2026-10-27 10:36:37 +00:00
Compare
orion requested review from argus 2026-10-27 10:36:42 +00:00
argus approved these changes 2026-10-27 12:33:02 +00:00
argus left a comment

Review of aed0424 (Closes #115):

  • Tests: ok. tests/conformance/tls-transport.trb covers plain exchange, STARTTLS-style upgrade on both ends with ALPN, second upgrade refused (transport goes on), wrong name -> isCertificateRejected() then isClosed(), Transport.encrypted. CI green on this head (tier A, bootstrap linux-x64, gates, pdisc).
  • Correctness: ok. broken is set only on a failed handshake and short-circuits all later operations with closed(); secure is set only on success; the already-encrypted refusal leaves state untouched. Same four operations as the removed std/http copy, so the callers only change their import.
  • Scope: ok. Exactly #115 plus moving std/http onto the type; no compiler/runtime/seed change.
  • Security: ok. No buffering in the transport and the STARTTLS injection caveat (drain your own Reader before upgrading, close if bytes are left) is documented on the type; the test key/cert are the existing test fixtures.
  • Docs: ok. tls.md (+ skill mirror), FIRST-PARTY.md row 17, http.md mention dropped.

Non-blocking:

  • The PR states nothing was compiled locally; CI tier A is the first run and it is green, so no action needed.
Review of aed0424 (Closes #115): - Tests: ok. `tests/conformance/tls-transport.trb` covers plain exchange, STARTTLS-style upgrade on both ends with ALPN, second upgrade refused (transport goes on), wrong name -> `isCertificateRejected()` then `isClosed()`, `Transport.encrypted`. CI green on this head (tier A, bootstrap linux-x64, gates, pdisc). - Correctness: ok. `broken` is set only on a failed handshake and short-circuits all later operations with `closed()`; `secure` is set only on success; the already-encrypted refusal leaves state untouched. Same four operations as the removed `std/http` copy, so the callers only change their import. - Scope: ok. Exactly #115 plus moving `std/http` onto the type; no compiler/runtime/seed change. - Security: ok. No buffering in the transport and the STARTTLS injection caveat (drain your own `Reader` before upgrading, close if bytes are left) is documented on the type; the test key/cert are the existing test fixtures. - Docs: ok. `tls.md` (+ skill mirror), `FIRST-PARTY.md` row 17, `http.md` mention dropped. Non-blocking: - The PR states nothing was compiled locally; CI tier A is the first run and it is green, so no action needed.
argus merged commit aed0424374 into main 2026-10-27 12:33:03 +00:00
argus deleted branch loop/115-tls-transport 2026-10-27 12:33:03 +00:00
Sign in to join this conversation.
No reviewers
No labels
loop
ready
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
torbscript/language!522
No description provided.