A SailfishOS (Jolla phone) client application for the Computer voice-assistant project
  • C++ 58.8%
  • Python 31.5%
  • QML 8.3%
  • QMake 1.4%
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
troed 35f2ed15e2 fix(backend): the realtime transport is wss-only; the RPM requires the CA (#4)
# fix(backend): the realtime transport is wss-only; the RPM requires the CA

Piece 4 (final piece) of the fleet TLS-only transport design —
`docs/superpowers/specs/2026-10-14-fleet-tls-only-design.md` (root repo). The
plan this implements:
`docs/superpowers/plans/2026-10-14-fleet-tls-piece-4-sailfish-enforcement.md`.

## The defect (shared by three repos)

TLS material was *optional* and its absence silently degraded the realtime
transport to plaintext `ws://`. In this repo, `qml/py/backend.py` resolved a CA
as argument → `STARFLEET_CA_BUNDLE` → `qml/py/starfleet-ca.pem`, and when all
three missed it set `ssl=None` and dialled `ws://`. On 2026-10-14 that failure
mode cost a debugging session: the attached ESP32 died at the WebSocket upgrade
because the server served `wss://` while the client spoke plaintext, and a
plaintext upgrade into a TLS listener is closed with zero bytes.

## What changes

**The client is wss-only** (`qml/py/backend.py`). The CA is resolved once, before
any connection attempt. A CA that resolves to nothing is a hard connect error
naming `STARFLEET_CA_BUNDLE`; a CA that is unreadable or unloadable still aborts
exactly as before. `scheme` is deleted — the URL is now a `wss://` literal and
`ssl_ctx` is always a real `SSLContext` by the time the loop runs, so there is no
branch left that can produce `ws://` or `ssl=None`, including on the automatic
reconnect.

**A blank error is now an error** (`_describe_connect_error`). Pointing this
client at a plaintext server raises `ConnectionResetError()` with no arguments,
whose `str()` is empty — the UI would have shown a *silent* failure. The message
falls back to the exception's type name.

**The test suite stops relying on the plaintext default.** One module-scoped
autouse fixture gives every backend test a single ephemeral throwaway CA minted
with `openssl`, and the real-server fixtures now serve TLS from a leaf signed by
it — the design's "ephemeral, in-test self-signed certificate", never the shared
dev set. The test asserting the old plaintext behaviour was **inverted, not
deleted**. Two tests were added for the cases the design's invariant implies:
a plaintext server with a CA configured, and a CA path that is a directory.

**The package step requires the CA** (`src/src.pro`). The install was
`exists()`-guarded, so an RPM built without `qml/py/starfleet-ca.pem` shipped an
app that aborts on first connect. A missing CA is now a qmake `error()` naming
the path. `tests/test_packaging.py` pins that structurally, because qmake and the
Sailfish SDK are not runnable on the host — it is a complement to the SDK build,
never the enforcement.

Dev runs use the shared dev set, either via `STARFLEET_CA_BUNDLE=$HOME/dev/starfleet/.dev-trust/ca.pem`
or by copying it to `qml/py/starfleet-ca.pem` before packaging (the dev set's
`server.pem`/`server.key` are what the `computer` server serves).

## Verification

```bash
cd communicator-sailfish
/tmp/opencode/sailfish-venv/bin/python -m pytest tests/ -q -p no:cacheprovider
# 39 passed   (35 before this branch; 30 is the stale number in AGENTS.md)
```

`openssl` is now needed by most of the suite (it was already needed by the two
handshake tests); `AGENTS.md` says so.

Whole-branch review by a fresh reviewer: **no Critical, no Important**; it
re-ran the changed tests against the pre-change tree in a throwaway copy and
confirmed the Review Focus tests genuinely go red on regression. Four Minor
findings were deferred, not fixed (see the PR discussion / the executor ledger).

## Notes

- The design's ordering is complete with this PR: generator (piece 1, esp32) →
  esp32 enforcement (#17) → `computer` enforcement (#19/#20) → sailfish.
- `qml/py/starfleet-ca.pem` stays gitignored and is never committed.
- This PR is opened against `main` — this repo has no `devel`.

Co-authored-by: Troed Sångberg <github@troed.se>
Reviewed-on: #4
2026-10-14 20:38:06 +02:00
audio harbour-communicator: Sailfish OS voice assistant client for the computer realtime server 2026-08-12 10:53:19 +02:00
docs/superpowers docs: Sailfish wss migration implementation plan 2026-09-11 21:08:47 +02:00
qml fix(backend): the realtime transport is wss-only; the RPM requires the CA (#4) 2026-10-14 20:38:06 +02:00
rpm fix(license): switch to CC0-1.0 (public domain)\n\nHarbour/sailfish convention is MIT for harbour-commons\nbut starfleet policy for bum bum forks is CC0 like\nroster and communicator-esp32. Add canonical CC0 LICENSE,\nset rpm spec License to CC0-1.0, and fix placeholder MIT\nin RESEARCH.md and implementation plan. 2026-08-26 21:17:26 +02:00
src fix(backend): the realtime transport is wss-only; the RPM requires the CA (#4) 2026-10-14 20:38:06 +02:00
tests fix(backend): the realtime transport is wss-only; the RPM requires the CA (#4) 2026-10-14 20:38:06 +02:00
.gitignore docs: ship the local CA in app resources for wss 2026-09-11 21:14:41 +02:00
AGENTS.md fix(backend): the realtime transport is wss-only; the RPM requires the CA (#4) 2026-10-14 20:38:06 +02:00
communicator.pro harbour-communicator: Sailfish OS voice assistant client for the computer realtime server 2026-08-12 10:53:19 +02:00
LICENSE fix(license): switch to CC0-1.0 (public domain)\n\nHarbour/sailfish convention is MIT for harbour-commons\nbut starfleet policy for bum bum forks is CC0 like\nroster and communicator-esp32. Add canonical CC0 LICENSE,\nset rpm spec License to CC0-1.0, and fix placeholder MIT\nin RESEARCH.md and implementation plan. 2026-08-26 21:17:26 +02:00
README.md fix(backend): the realtime transport is wss-only; the RPM requires the CA (#4) 2026-10-14 20:38:06 +02:00
RESEARCH.md fix(license): switch to CC0-1.0 (public domain)\n\nHarbour/sailfish convention is MIT for harbour-commons\nbut starfleet policy for bum bum forks is CC0 like\nroster and communicator-esp32. Add canonical CC0 LICENSE,\nset rpm spec License to CC0-1.0, and fix placeholder MIT\nin RESEARCH.md and implementation plan. 2026-08-26 21:17:26 +02:00

harbour-communicator

Connection security (wss)

In production the realtime connection is wss://, validated against the Starfleet local CA. The CA certificate is shipped inside the app's QML resources at qml/py/starfleet-ca.pem (installed to /usr/share/harbour-communicator/qml/py/); the packaging step places the real CA there before building the RPM. The file is gitignored and never committed. The qmake install rule requires the file: a build without it fails in qmake with an error naming the path, rather than producing an RPM whose app aborts at first connect. For a dev packaging run, copy the shared dev CA there first:

cp $HOME/dev/starfleet/.dev-trust/ca.pem qml/py/starfleet-ca.pem

The client is wss://-only: there is no plaintext path and no switch that turns TLS off. If no CA resolves, the connect fails immediately with an error naming STARFLEET_CA_BUNDLE, rather than silently falling back to ws://.

For a dev run against the shared dev set, point the env var at it:

STARFLEET_CA_BUNDLE=$HOME/dev/starfleet/.dev-trust/ca.pem