Files
hermeven/docs/handoff/2026-11-18-cody-round-3.md
T
DanandClaude Fable 5.2 e1c02d5266 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>
2026-11-18 19:49:14 -08:00

75 lines
5.8 KiB
Markdown

# Handoff for Cody, Round 3
From: Claude (implementation). Date: 2026-11-18.
**Not reviewed.** Cody's Round 2 verdict (NEEDS CHANGES) applies to `3d5691d` only. Nothing below
is a claim that any finding is closed; that is Cody's call on the new SHA.
| Item | Value |
|---|---|
| Repository | `git@git.xylo.gg:Xylo-Digital/hermeven.git` |
| Branch | `cody/slice-1-review` |
| Reviewed in Round 2 | `3d5691dfa3e3015f7d0e4f760de60c588ffea0dc` |
| `main` | `0c9dcd864f16782097471e5bbf57cbd701c26616` (unchanged; nothing merged) |
| New head for Round 3 | the tip of `cody/slice-1-review` after this push; the exact SHA is in the push report, since a file cannot contain its own commit id |
## What was done for each finding
| Finding | Change | Where |
|---|---|---|
| CODY-001 | Bridge URL must be HTTPS; HTTP only for `localhost`, `127.x.x.x`, `[::1]` (exact match). Same rule in the manifest generator, which exits 1. URLs with embedded credentials are refused. | `net/bridgeClient.ts`, `scripts/write-manifest.mjs` |
| CODY-002 | The host-call queue advances only when the SDK call has actually settled; the caller's timeout is a separate, bounded answer. A start that times out queues a stop behind it. The controller stops unconditionally when a capture was abandoned while opening. | `device/evenAdapter.ts`, `core/controller.ts` |
| CODY-003 | The request id is stored before the first submit and cleared only on a terminal result, a definite rejection, or the bridge confirming it has no such turn. An undelivered cancel is remembered and retried at next start. The HUD says "not confirmed yet" instead of "has not been sent". | `core/controller.ts`, `core/hud.ts` |
| CODY-004 | `Devices.revoke` flags every non-terminal turn of the device in the same transaction that revokes it. `TurnEngine.revokeDevice` (HTTP path) applies the flags at once; a one-second sweep applies flags written by the CLI process. Workers abort transcription and ask Hermes to stop. | `devices.ts`, `turns.ts`, `server.ts`, `app.ts` |
| CODY-005 | Manifests pin a 40-character commit id and a SHA-256 and size per file (`services/bridge/models/`). `fetch-model` downloads and verifies; the worker verifies on every load, disables remote models, and loads only from the store. No unpinned configuration exists. | `stt/modelStore.mjs`, `stt/whisperWorker.mjs`, `config.ts`, `cli.ts`, `deploy/*` |
| CODY-006 | Database file is created 0600 before SQLite opens it, in a 0700 directory; WAL and SHM inherit. Unit sets `UMask=0077` and a 0700 state directory. | `db.ts`, `deploy/hermeven-bridge.service`, `docs/deploy-droplet.md` |
| CODY-007 | `credential_expired` is handled like `unauthorized` on every runtime path (submit, poll, cancel, status refresh, renew, conversation create). | `core/controller.ts` |
| CODY-008 | `approval_started_at` is written once, when the approval is first seen (it was previously rewritten on every poll). The agent deadline is stored in a new column and updated in the same write that ends an approval wait. Both are restored after a restart. Schema migration v2. | `turns.ts`, `db.ts` |
| CODY-009 | One in-flight create per conversation epoch, shared by the menu action and the lazy first-turn path; creates are sent strictly in sequence; a result for a replaced conversation is dropped before persistence. A second "new conversation" while one is pending does nothing. | `core/controller.ts`, `core/reducer.ts` |
| CODY-010 | Wrong guesses no longer count against the outstanding code. Brute force is bounded by 49 bits of entropy, a 5-minute lifetime and the per-address limit. Wrong, expired and used codes return the same response. `pairing_locked` is reserved and no longer returned. | `devices.ts`, `server.ts` |
The tests for each are listed in `docs/test-evidence.md` under "Round 3".
## Check results
| Check | Result |
|---|---|
| `npm run typecheck` | exit 0 |
| `npm test` | 182 passed, 0 failed |
| `npm run client:build` | built |
| `npm run test:real-stt` | 11 passed, 0 failed |
| `npm run test:real-hermes` | 9 passed, 0 failed |
| `npm run test:simulator` | 6 passed, 0 failed |
| `git diff --check` | clean |
No check was omitted.
## Decisions made while fixing, for Cody to judge
- **CODY-010 uses entropy and a per-address limit, with no global cap.** A global cap would let a
flood block the owner's own pairing, which is the same denial of service by another route. The
arithmetic is in `docs/security.md`.
- **CODY-009 keys the result check to a conversation epoch, not the turn generation.** A question
asked while the conversation is being created bumps the turn generation; a strict generation
check would throw away the conversation that question is waiting for.
- **CODY-005 removes the automatic first-start download entirely**, including for development.
- **CODY-004 through the CLI is honoured within the sweep interval (1 s)**, not instantly, because
the CLI is a separate process with no channel to the running bridge other than the database.
- **CODY-003: after a restart, a voice question that never reached the bridge cannot be resent**,
because the recording lived only in memory. The user is told to ask again, and only after the
bridge has confirmed it has no record of the request.
## Things the author is unsure about
- `whisperWorker.mjs` and `modelStore.mjs` are plain JavaScript, typed only through a hand-written
declaration file.
- Between verifying the model files and loading them there is a short window; a read-only model
directory closes it, and that is a deployment setting, not something the code enforces.
- The CODY-006 test observes permissions at each `chmod` call, not continuously.
- A device revoked through the CLI while its turn is still being submitted to Hermes relies on the
poll loop noticing the flag after admission.
## Not claimed
No physical device, no droplet, no deployment, no production change. Nothing merged to `main`.