Files
hermeven/docs/handoff/2026-11-18-slice-1.md
T
DanandClaude Fable 5.2 0c9dcd864f Run Whisper in a worker thread; shorten polling
The speech model now lives in a worker thread (whisperWorker.mjs), so
loading and transcribing no longer block the bridge's HTTP server or its
Hermes polling. Measured longest event-loop pause during transcription:
387 ms before, 3 ms after. A dead worker is replaced on the next request;
closing the bridge terminates it.

Polling: bridge to Hermes every 150 ms (was 500). The app polls the bridge
every 200 ms for the first 8 s of a turn, 400 ms until 30 s, then 1 s
(was a fixed 700 ms).

Tests: 131 unit/integration, 7 real-speech, 9 real-Hermes, 6 simulator,
all passing. Effect on a phone or a droplet is not measured.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-18 18:39:28 -08:00

132 lines
7.1 KiB
Markdown

# Handoff: first vertical slice
To: Cody (architecture and security review), Dan (scope, merge).
From: Claude (implementation). Date: 2026-11-18.
**This work has not been reviewed.** Nothing below is a review conclusion, and no part of it
should be read as Cody's assessment. The author's own checks are listed as such.
## Identity of what is being handed over
| Item | Value |
|---|---|
| Repository | `git@git.xylo.gg:Xylo-Digital/hermeven.git` |
| Base | None. The remote had no refs when work began (empty repository), so there is no base SHA. |
| Branch | `feat/vertical-slice-1`, local only |
| First slice | `4687cc01147e2167997aa6a252343933070fbebd` |
| Head under review | The tip of the remote branch `cody/slice-1-review`: the first slice plus built-in speech-to-text and droplet deployment files (see "Added after the first slice"). |
| Pushed | To `cody/slice-1-review` only, at Dan's request on 2026-11-18. Dan works solo and has said no PR is needed. Nothing has been pushed to `main`. |
Repository instructions: there were none to follow (no `AGENTS.md`, `CLAUDE.md`, `README` or
`CONTRIBUTING` existed). The kickoff specification was the only instruction source.
## Added after the first slice
Dan decided speech-to-text should be built into the software and that the bridge will run on a
DigitalOcean droplet.
| Area | Paths |
|---|---|
| Built-in Whisper adapter, now the default `STT_PROVIDER` | `services/bridge/src/stt/builtinWhisper.ts`, `config.ts`, `app.ts`, `main.ts` |
| Tests | `services/bridge/test/builtinWhisper.test.ts`, `tests/real-stt/*` (with a public-domain speech fixture) |
| Deployment examples, **not run on a droplet** | `deploy/*`, `docs/deploy-droplet.md` |
| New dependency | `@huggingface/transformers` 4.3.2 (brings ONNX Runtime and `sharp`) |
| Whisper moved to a worker thread; polling shortened (bridge 150 ms; app 200/400/1000 ms by elapsed time) | `services/bridge/src/stt/whisperWorker.mjs`, `builtinWhisper.ts`, `config.ts`, `apps/even-client/src/core/controller.ts` |
## Changed files
Everything is new. 79 files at the head above.
| Area | Paths |
|---|---|
| Contract | `packages/contracts/src/{schemas,errors,index}.ts` |
| Bridge | `services/bridge/src/{config,db,devices,turns,server,app,main,cli,env,ratelimit}.ts`, `hermes/{adapter,runsAdapter}.ts`, `stt/{adapter,openaiCompatible}.ts` |
| Client | `apps/even-client/src/core/{reducer,controller,hud,paginate,plaintext}.ts`, `device/{port,events,evenAdapter,previewDevice}.ts`, `net/bridgeClient.ts`, `ui/phone.{ts,css}`, `main.ts`, `app.template.json`, `scripts/write-manifest.mjs` |
| Tests | `tests/fakes/*`, `tests/integration/*`, `tests/simulator/*`, `tests/real-hermes/*`, and `test/` in each package |
| Docs | `README.md`, `docs/*` |
Roughly 4,400 lines of source and 3,200 lines of tests.
## Commands and real results
Full detail, including failures along the way, is in `docs/test-evidence.md`.
| Command | Result |
|---|---|
| `npm ci` | clean install, 0 vulnerabilities reported |
| `npm run typecheck` | exit 0 |
| `npm test` | 131 passed, 0 failed (8 files) |
| `npm run test:real-stt` | 7 passed, 0 failed |
| `npm run test:simulator` | 6 passed, 0 failed; 10 consecutive runs of the final revision |
| `npm run test:real-hermes` | 9 passed, 0 failed |
| `npm run client:build` | built; bundle searched for server secrets, none |
| `evenhub pack ... --sdk-ver 0.0.16` | manifest accepted, `min_app_version 2.2.10`; not uploaded |
## Evidence by kind
| Kind | What exists |
|---|---|
| Fakes only | 122 tests |
| Even simulator 0.9.5 | 6 scenarios, screenshots in `docs/evidence/simulator/` |
| Real Hermes v0.23.1, stub model | 9 scenarios |
| Real STT | 7 scenarios: built-in Whisper on one clean archive recording |
| Real model or tools | none |
| Physical device | **none** |
## Where the specification was not followed as written, and why
1. **Hermes Runs API instead of `/v1/responses`.** `docs/decisions/0002-hermes-runs-api.md`.
2. **Two endpoints beyond the proposed list**: `POST /v1/pairing/claim` and `/v1/device`
(status, renew, revoke). The specification required pairing, status and disconnect but listed
no routes for them.
3. **Audio metadata in the query string** with a raw binary body, rather than multipart.
4. **No SSE endpoint.** Polling only.
5. **`approval_required` is a non-terminal state**, not a terminal outcome. An approval that
never arrives ends as `cancelled` with code `approval_timeout`.
6. **The bridge caches question and answer text for 15 minutes** so a client can poll for its
result and recover after a restart. The specification says the bridge stores opaque references,
not a transcript.
7. **The device token lasts 7 days**, renewable within a 90-day pairing. The specification
preferred short-lived.
8. **No latency percentiles are documented.** There is nothing real to measure yet.
9. **Not done from the implementation sequence:** step 2's "real G2 input and HUD" and step 3's
real microphone and real STT. They need the device and a provider.
## Things the author is unsure about
Offered as places to look, not as findings.
- Whether double tap as "cancel" away from the root page satisfies Even's exit rule.
- Whether classifying "stop requested but the run completed first" as `succeeded` is the right
thing to show a user who pressed cancel.
- Whether the fixed-window, in-memory rate limiter and the unbounded-by-IP pairing lockout (any
client can burn the owner's outstanding pairing code with five bad guesses) are acceptable.
- Token renewal that needs only the current token.
- `services/bridge/src/turns.ts` builds an `UPDATE` statement from object keys. The keys are
compile-time constants in this file, not request data.
- The Hermes adapter does not yet check `/v1/capabilities` for durable idempotency at startup.
- The client holds captured audio in memory for a possible resend until the user discards it.
- The real-Hermes test covers neither approvals nor the `unknown` status.
- The built-in speech model is fetched from the Hugging Face hub at first start with no pinned
revision or hash. It runs in a worker thread of the bridge process, in plain JavaScript
(`whisperWorker.mjs`) that the type checker does not cover.
- The silence threshold in `builtinWhisper.ts` was chosen without any audio from the glasses.
- The systemd hardening options in `deploy/` have never been run with ONNX Runtime.
## Blockers and open decisions
| # | Item | Owner |
|---|---|---|
| 1 | Run `docs/device-test-plan.md`, starting with A13 (locked phone, pocket). | Dan |
| 2 | ~~Choose an STT provider.~~ Decided: built in. Remaining: measure it on the droplet. | Dan |
| 3 | Name the target Hermes deployment and a safe test profile. | Dan |
| 4 | ~~Push and PR.~~ Decided: no PR; pushed to `cody/slice-1-review`. When to put it on `main` is still open. | Dan |
| 5 | Independent architecture and security review of the head above. | Cody |
| 6 | Distribution model given Even's per-build network whitelist. | Dan, later |
## Not claimed
No deployment. No working hardware. No production change. No paid service used. No upload to
Even's portal. No change to any Hermes installation: the real-Hermes test used a throwaway home
directory that was deleted afterwards.