devel #22

Merged
troed merged 13 commits from devel into main 2026-10-17 19:45:27 +02:00
Owner
No description provided.
docs: point the canonical realtime README at the required TLS material
All checks were successful
CI / Sanity check (ubuntu-latest) (pull_request) Successful in 4m15s
311bfdd0f1
# 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
```

Co-authored-by: Troed Sångberg <github@troed.se>
Reviewed-on: #21
A turn that completes with nothing to say used to end in dead air: no TTS, no
audio and no error for the client, which then waited in its listening state
until it timed out.

Field case (server journal, turn_25): the backend answered with 512 tokens --
exactly max_output_tokens, i.e. truncated at the cap -- while emitting no
content chunk at all and no tool call. TTS therefore never ran, the response
carried zero audio bytes ("response complete (no audio gate)") and the device
heard nothing. The device itself was fine: VAD confirmed 3.6 s of speech and
the question transcribed cleanly.

- LLM backends: when a stream ends with no assistant text and no tool call,
  report the raw shape -- chunk count, the non-empty delta fields seen, the
  stop reason. A provider field the mapper does not read (reasoning tokens, a
  tool call that never parsed) is then provable from the log instead of
  guessed at. Fields land in ``model_extra`` when the OpenAI SDK does not
  model them, so both places are read.
- base: if a turn yields no chunk at all and did not fail, speak a brief
  fallback so the session continues instead of hanging.
- tests: the fallback (streaming and non-streaming), its absence when text is
  spoken or only a tool is called, and the diagnostics naming a non-standard
  provider field. ``test_non_streaming_empty_choices_completes_cleanly`` now
  expects the fallback: its old expectation (silence) was the behaviour that
  produced the field symptom.
Merge branch 'fix/llm-empty-output-fallback' into devel
Some checks failed
CI / Sanity check (ubuntu-latest) (pull_request) Has been cancelled
94e76d1d6f
Merge branch 'main' into devel
Some checks failed
CI / Sanity check (ubuntu-latest) (pull_request) Failing after 2m25s
7c1a444b23
troed merged commit d77793e791 into main 2026-10-17 19:45:27 +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!22
No description provided.