fix(review): work through the deferred TLS-only review minors #21

Merged
troed merged 2 commits from fix/fleet-tls-review-minors-computer into devel 2026-10-14 22:31:49 +02:00
Owner

fix(review): work through the deferred TLS-only review minors

The computer half of the deferred review minors in HANDOVER.md §3.5 —
the findings recorded during piece 3's per-task and whole-branch reviews and
triaged "ship, not blocking". This is the computer peer of esp32 PR #19
(the trust-tool minors).

Nothing here changes the shipped behaviour of the TLS-only transport. It
closes the gaps the reviewers flagged: swallowed errors, untested guards, one
removed plaintext affordance, and two pieces of test hygiene.

What changes

The server's certificate-subject log learns its exceptions. cert_subject
wrapped the private ssl._ssl._test_decode_cert in a bare except Exception.
It now catches only the unreadable-file cases — ssl.SSLError, OSError,
ValueError — each of which was verified against a missing, garbage,
directory, empty and truncated file (all raise ssl.SSLError). A genuine bug
now surfaces instead of vanishing into <unreadable>.

The python -O hole is closed. s2s_pipeline.build_pipeline used
assert server_tls is not None in the websocket and realtime branches; under
-O that vanishes, and a None would flow into WebSocketStreamer/
RealtimeServer. Both now raise a named RuntimeError, and a test forces the
branch with None to prove the guard is real.

Three startup guards are now pinned by tests: RealtimeServer.__init__
(empty pool; each missing/empty/partial cert+key combination — the one guard
piece 3 left untested), the socket-mode TLS exemption
(build_pipeline(mode="socket") must not call require_server_tls at all),
and the <empty> subject branch.

One plaintext affordance removed. listen_and_play_realtime.py accepted a
plaintext --websocket-base-url; it now rejects a non-wss:// value exactly as
synthetic_conversation_realtime_client.py already did. test_audio_path.py's
test_live(..., ca_bundle=None) also loses its optional default, which would
have silently fallen back to the system trust store.

Test hygiene. test_client_capture_mode.py drops its hard-coded
computer-test-ca PEM in favour of the session's throwaway self_signed_cert
fixture. The resolve_trust_dir default-path test is no longer tautological: it
derives the repo root from the test file rather than the module under test, and
asserts the default is a sibling of the repo, never nested inside it.

The static fence gets behavioural companions. tests/test_tls_invariant.py
now drives both URL-accepting scripts' own CLIs and asserts a ws:// argument
is refused with exit 2. The grep fence stays as the CI-side complement; the
behaviour is now pinned directly.

Deliberate non-changes (with reasons)

  • __file__-derived default dev-trust path. The design says the default is
    ../.dev-trust relative to the consuming repo — a source-checkout notion.
    A non-editable install derives a wrong site-packages path, but nothing ever
    silently serves with it: require_server_tls fails loudly when
    server.pem/server.key are absent and names STARFLEET_TRUST_DIR as the
    remedy. The docstring now says this outright.
  • STT/README.md / TTS/README.md snippet lists. Their invocations serve a
    socket and so need TLS material, but they are covered by the pointer sentence
    in computer/README.md that names both files and states the requirement. The
    snippets stay as-is rather than duplicating the flags into ~15 examples.
  • The superseded sentence in the dated plan docs/plans/2026-09-10-ota-computer.md
    is corrected in place and marked superseded, rather than left to mislead.

Review follow-up

Whole-branch review returned no Critical and no Important findings. The worthwhile
Minors were folded in as a second commit: the superseded pointer is qualified as
the root repo's spec, the websocket branch gets the mirror of the realtime -O
guard test, _load_script uses a private module name, the CLI guard tests assert
the wss message (not just exit 2), and test_audio_path.py --live is driven as
a CLI to pin item 10's behaviour rather than only its type signature.

Verification

Sandbox suite: 980 passed, 1 deselected (968 before; 12 tests added).
ruff check / ruff format --check / mypy src/ clean. Public-repo hygiene
scan over the added lines clean.

cd $HOME/dev/starfleet/computer
env -u ALL_PROXY -u HTTP_PROXY -u HTTPS_PROXY -u all_proxy -u http_proxy -u https_proxy \
  PYTHONPATH=/tmp/opencode/sdstub .venv/bin/python -m pytest tests/ -q -p no:cacheprovider \
    --ignore=tests/test_chat_completions_backend.py \
    --ignore=tests/test_responses_api_language_model.py \
    --ignore=tests/test_voice_prompt.py \
    --deselect tests/test_omnivoice_tts_handler.py::test_setup_flashinfer_import_failure_raises
# fix(review): work through the deferred TLS-only review minors The `computer` half of the deferred review minors in `HANDOVER.md` §3.5 — the findings recorded during piece 3's per-task and whole-branch reviews and triaged "ship, not blocking". This is the `computer` peer of esp32 PR #19 (the trust-tool minors). Nothing here changes the shipped behaviour of the TLS-only transport. It closes the gaps the reviewers flagged: swallowed errors, untested guards, one removed plaintext affordance, and two pieces of test hygiene. ## What changes **The server's certificate-subject log learns its exceptions.** `cert_subject` wrapped the private `ssl._ssl._test_decode_cert` in a bare `except Exception`. It now catches only the unreadable-file cases — `ssl.SSLError`, `OSError`, `ValueError` — each of which was verified against a missing, garbage, directory, empty and truncated file (all raise `ssl.SSLError`). A genuine bug now surfaces instead of vanishing into `<unreadable>`. **The `python -O` hole is closed.** `s2s_pipeline.build_pipeline` used `assert server_tls is not None` in the websocket and realtime branches; under `-O` that vanishes, and a `None` would flow into `WebSocketStreamer`/ `RealtimeServer`. Both now raise a named `RuntimeError`, and a test forces the branch with `None` to prove the guard is real. **Three startup guards are now pinned by tests:** `RealtimeServer.__init__` (empty pool; each missing/empty/partial cert+key combination — the one guard piece 3 left untested), the `socket`-mode TLS exemption (`build_pipeline(mode="socket")` must not call `require_server_tls` at all), and the `<empty>` subject branch. **One plaintext affordance removed.** `listen_and_play_realtime.py` accepted a plaintext `--websocket-base-url`; it now rejects a non-`wss://` value exactly as `synthetic_conversation_realtime_client.py` already did. `test_audio_path.py`'s `test_live(..., ca_bundle=None)` also loses its optional default, which would have silently fallen back to the system trust store. **Test hygiene.** `test_client_capture_mode.py` drops its hard-coded `computer-test-ca` PEM in favour of the session's throwaway `self_signed_cert` fixture. The `resolve_trust_dir` default-path test is no longer tautological: it derives the repo root from the test file rather than the module under test, and asserts the default is a *sibling* of the repo, never nested inside it. **The static fence gets behavioural companions.** `tests/test_tls_invariant.py` now drives both URL-accepting scripts' own CLIs and asserts a `ws://` argument is refused with exit 2. The grep fence stays as the CI-side complement; the behaviour is now pinned directly. ## Deliberate non-changes (with reasons) - **`__file__`-derived default dev-trust path.** The design says the default is `../.dev-trust` *relative to the consuming repo* — a source-checkout notion. A non-editable install derives a wrong `site-packages` path, but nothing ever silently serves with it: `require_server_tls` fails loudly when `server.pem`/`server.key` are absent and names `STARFLEET_TRUST_DIR` as the remedy. The docstring now says this outright. - **`STT/README.md` / `TTS/README.md` snippet lists.** Their invocations serve a socket and so need TLS material, but they are covered by the pointer sentence in `computer/README.md` that names both files and states the requirement. The snippets stay as-is rather than duplicating the flags into ~15 examples. - **The superseded sentence in the dated plan** `docs/plans/2026-09-10-ota-computer.md` is corrected in place and marked superseded, rather than left to mislead. ## Review follow-up Whole-branch review returned no Critical and no Important findings. The worthwhile Minors were folded in as a second commit: the superseded pointer is qualified as the root repo's spec, the websocket branch gets the mirror of the realtime `-O` guard test, `_load_script` uses a private module name, the CLI guard tests assert the `wss` message (not just exit 2), and `test_audio_path.py --live` is driven as a CLI to pin item 10's behaviour rather than only its type signature. ## Verification Sandbox suite: **980 passed, 1 deselected** (968 before; 12 tests added). `ruff check` / `ruff format --check` / `mypy src/` clean. Public-repo hygiene scan over the added lines clean. ```bash cd $HOME/dev/starfleet/computer env -u ALL_PROXY -u HTTP_PROXY -u HTTPS_PROXY -u all_proxy -u http_proxy -u https_proxy \ PYTHONPATH=/tmp/opencode/sdstub .venv/bin/python -m pytest tests/ -q -p no:cacheprovider \ --ignore=tests/test_chat_completions_backend.py \ --ignore=tests/test_responses_api_language_model.py \ --ignore=tests/test_voice_prompt.py \ --deselect tests/test_omnivoice_tts_handler.py::test_setup_flashinfer_import_failure_raises ```
fix(review): work through the deferred TLS-only review minors
All checks were successful
CI / Sanity check (ubuntu-latest) (pull_request) Successful in 4m23s
5ad789c914
The `computer` half of HANDOVER §3.5: the minors recorded during piece 3's
per-task and whole-branch reviews. Each was triaged "ship"; this is the
one-line upgrade path each deserved.

Server trust material (`server_tls.py`)
- `cert_subject` no longer swallows `Exception` around the private decoder;
  it catches only the unreadable-file cases (`ssl.SSLError`/`OSError`/
  `ValueError`) -- proven against a missing, garbage, directory, empty and
  truncated file, all of which raise `ssl.SSLError`. A real bug now surfaces.
- The `<empty>` subject branch is tested (monkeypatch the decoder), and so is
  the propagate-an-unexpected-error case.
- The default dev-trust path is documented as checkout-relative: a
  non-editable install derives a wrong `site-packages` path, but
  `require_server_tls` already fails loudly there and names
  `STARFLEET_TRUST_DIR`. No silent serving, so no code change.

Startup guards
- `s2s_pipeline.build_pipeline` no longer uses `assert server_tls is not None`
  (dropped under `python -O`) in the websocket/realtime branches; both raise a
  named `RuntimeError`, with a test that forces the branch with `None`.
- `RealtimeServer.__init__`'s previously untested guard is pinned (empty pool;
  each missing/empty/partial cert+key combination).
- The `socket`-mode exemption is now tested: `build_pipeline(mode="socket")`
  must not call `require_server_tls` at all.

Scripts and fences
- `listen_and_play_realtime.py` rejects a plaintext `--websocket-base-url`,
  mirroring `synthetic_conversation_realtime_client.py`.
- `test_audio_path.test_live`'s `ca_bundle` is required (`str`), not an
  optional `str | None` that would fall back to the system default.
- `tests/test_tls_invariant.py` grows behavioural companions to its static
  fence: it drives both URL-accepting scripts' CLIs and asserts a `ws://`
  argument is refused (exit 2). The fence stays as the CI-side complement.
- Dead `_ota_schedule_frame` helper removed from the conformance test double.

Test hygiene
- `test_client_capture_mode.py` drops its hard-coded `computer-test-ca` PEM and
  uses the session's throwaway `self_signed_cert` fixture instead.
- `test_resolve_trust_dir_defaults_to_the_sibling_dev_set` is no longer
  tautological: it derives the repo root from the test file (not the module
  under test) and asserts the default is a *sibling*, never nested.

Docs
- The superseded "plaintext ws:// otherwise" sentence in the dated
  `docs/plans/2026-09-10-ota-computer.md` is corrected and marked superseded.

The `src/computer/STT|TTS/README.md` snippet lists are left as-is: the pointer
sentence in `computer/README.md` (naming both files) is their coverage.

Verification: 978 passed, 1 deselected (968 before; 10 tests added), `ruff
check` / `ruff format --check` / `mypy src/` clean, hygiene scan on added lines
clean.
fix(review): address the review minors on the computer review-minors branch
All checks were successful
CI / Sanity check (ubuntu-latest) (pull_request) Successful in 4m24s
45fc03e5ab
Whole-branch review of the previous commit found no Critical and no Important
items; these are the worthwhile Minors.

- The superseded-pointer added to `docs/plans/2026-09-10-ota-computer.md` is
  qualified as the *root repo's* spec: the path as written did not resolve from
  inside `computer/`.
- The websocket branch's `python -O` guard gets the mirror of the realtime
  test, so both replaced `assert`s are pinned rather than one.
- `_load_script` registers its dynamically-imported script under a private
  name and removes it afterwards, so a same-basename module elsewhere cannot
  collide.
- The two CLI guard tests now assert the `wss` message, not just exit 2, so a
  reorder of the `parser.error` checks cannot satisfy them vacuously.
- `test_audio_path.py --live` is driven as a CLI without a bundle and must exit
  2, so item 10's behaviour is tested, not only its type signature.

980 passed, 1 deselected (978 before); ruff/format/mypy clean.
troed merged commit a9700eb8e5 into devel 2026-10-14 22:31:49 +02:00
troed deleted branch fix/fleet-tls-review-minors-computer 2026-10-14 22:31:49 +02:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
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
starfleet/computer!21
No description provided.