Address Cody review round 2: all ten findings (CODY-001 to CODY-010)

CODY-001 Bridge URL must be HTTPS (HTTP only to loopback), in the client and
         in manifest generation.
CODY-002 Even host calls stay serialised until the SDK call really settles;
         a microphone start that completes after its timeout is followed by
         a stop.
CODY-003 Request id is stored before the first submit and cleared only on a
         definitive answer; lost replies are treated as ambiguous and
         reconciled under the same id; HUD no longer claims "not sent".
CODY-004 Revoking a device cancels its in-flight turns, aborts
         transcription and asks Hermes to stop, from HTTP and CLI paths.
CODY-005 Speech model pinned to a commit with per-file SHA-256; fetched and
         verified ahead of time; verified on every load; never downloaded
         at run time; no unpinned configuration.
CODY-006 State directory 0700, database/WAL/SHM 0600 regardless of umask.
CODY-007 credential_expired handled like unauthorized on every path.
CODY-008 Approval wait start and paused agent deadline persisted and
         restored across restarts (schema v2).
CODY-009 Exactly one conversation create per epoch, sent in sequence, with
         stale results dropped before persistence.
CODY-010 Wrong pairing guesses no longer consume the outstanding code;
         failures are indistinguishable.

Checks: typecheck clean; npm test 182 passed; client build ok;
test:real-stt 11 passed (including with no network); test:real-hermes 9
passed; test:simulator 6 passed; git diff --check clean.

Not reviewed. No physical-device, droplet or production evidence.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
Dan
2026-11-18 19:49:14 -08:00
co-authored by Claude Fable 5.2
parent 3d5691dfa3
commit e1c02d5266
43 changed files with 2104 additions and 227 deletions
+16 -4
View File
@@ -29,7 +29,7 @@ weights:
| Memory after transcribing | about 0.8 GB |
| 11 s of speech, process pinned to one core | about 1.7 s |
| Same, `whisper-tiny` | about 1.2 s, about 0.6 GB |
| Model download on first start | about 80 MB (`base`), cached afterwards |
| Model download at deploy time (`fetch-model`) | 79 MB (`whisper-base`), 4 s on the desktop's connection |
| Longest pause of the bridge's event loop while transcribing | 3 ms (the model runs in a worker thread) |
Pinning to one core made no difference to speed, so extra cores will not help; a single droplet
@@ -41,8 +41,8 @@ Suggested starting point, to be confirmed by measuring on the droplet: **2 GB RA
for the bridge alone. 1 GB is likely too tight alongside the OS. If Hermes shares the droplet,
add whatever Hermes needs; that was not measured.
If transcription is too slow on the droplet, set `STT_MODEL=onnx-community/whisper-tiny`
(faster, less accurate) or, for English only, `onnx-community/whisper-base.en`.
If transcription is too slow on the droplet, set `STT_MODEL=whisper-tiny` (faster, less
accurate) and run `fetch-model` again.
## Steps
@@ -59,11 +59,22 @@ If transcription is too slow on the droplet, set `STT_MODEL=onnx-community/whisp
needed: the bridge runs through `tsx`.)
5. **Configuration.** Copy `deploy/bridge.env.example` to `/etc/hermeven/bridge.env`, fill it
in, `chmod 600`, `chown hermeven`.
5a. **Speech model.** As root (not the service user), fetch and verify the pinned model into a
directory the service can read but not write:
```sh
HERMEVEN_ENV_FILE=/etc/hermeven/bridge.env npm --prefix /opt/hermeven run bridge:cli -- fetch-model
HERMEVEN_ENV_FILE=/etc/hermeven/bridge.env npm --prefix /opt/hermeven run bridge:cli -- verify-model
```
Every file is checked against the SHA-256 committed in `services/bridge/models/`. The running
service never downloads anything: it re-verifies these files each time it loads the model and
refuses to load if one is missing or different. This is the only step that needs outbound
access to huggingface.co.
6. **Hermes.** Enable its API server with a key, bound to `127.0.0.1`. Use a read-only or test
profile first.
7. **Service.** Copy `deploy/hermeven-bridge.service` to `/etc/systemd/system/`, then
`systemctl daemon-reload && systemctl enable --now hermeven-bridge`. Watch
`journalctl -u hermeven-bridge -f` for `stt.ready` (the first start downloads the model).
`journalctl -u hermeven-bridge -f` for `stt.ready`. `stt.load_failed` with `reason: missing`
or `mismatch` means step 5a was skipped or the files changed.
8. **TLS.** Put `deploy/Caddyfile.example` at `/etc/caddy/Caddyfile` with your hostname, reload
Caddy, then check `curl https://bridge.example.com/healthz`.
9. **App build.** On your own machine:
@@ -80,6 +91,7 @@ If transcription is too slow on the droplet, set `STT_MODEL=onnx-community/whisp
- Time from `stt.loading` to `stt.ready`, and memory of the service after a few questions.
- `transcribe_ms` for a few real questions (the phone page shows it per question).
- That `curl http://<droplet-ip>:8787/healthz` from outside **fails** (bridge not exposed).
- `stat -c '%a' /var/lib/hermeven /var/lib/hermeven/hermeven.sqlite*` shows `700` and `600`.
- That the unit's hardening options do not stop the model loading. `ProtectSystem=strict` and
`MemoryMax` in particular are untested with ONNX Runtime.