Address Cody review round 3: CODY-003 and CODY-006
CODY-003 Request identity is durable before submission. Storage results are
explicit at the DevicePort boundary (storageSet resolves true only
on the host's own timely confirmation; storageGet distinguishes
unknown from empty). A request is not sent until the phone has
confirmed storing its id; a timeout or refusal holds it back,
unsent and retryable under the same id. Unreadable storage at
start is not treated as unpaired; an unsaveable pairing is revoked.
CODY-006 The state directory is set to 0700 on every open, including when
it already existed, and the bridge refuses to start with an
operator-facing error if it cannot be. Deployment guide creates
it with install -d -m 0700.
Checks: typecheck clean; npm test 194 passed; client build ok;
test:real-stt 11 passed; 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:
@@ -66,6 +66,8 @@ accepted -> transcribing -> thinking -> done
|
||||
|
||||
Order of operations for one turn:
|
||||
|
||||
0. On the phone, before any of this: the app stores the request id in app storage and waits
|
||||
for the host to confirm the write. No confirmation, no request.
|
||||
1. Validate, authenticate, check the conversation belongs to the device and is open, and that no
|
||||
other turn is running in it. Insert the turn row keyed by the client's request id. A repeat of
|
||||
the same request id returns the existing turn.
|
||||
|
||||
@@ -52,9 +52,13 @@ accurate) and run `fetch-model` again.
|
||||
3. **User and directories.**
|
||||
```sh
|
||||
useradd --system --home /opt/hermeven --shell /usr/sbin/nologin hermeven
|
||||
mkdir -p /opt/hermeven /var/lib/hermeven /etc/hermeven
|
||||
chown hermeven:hermeven /var/lib/hermeven
|
||||
mkdir -p /opt/hermeven /etc/hermeven
|
||||
# The state directory is the service user's alone: mode 0700, set explicitly.
|
||||
install -d -m 0700 -o hermeven -g hermeven /var/lib/hermeven
|
||||
```
|
||||
The bridge also enforces this itself: at start it sets the directory that holds the database
|
||||
to 0700 even if it already existed with looser permissions, and refuses to start if it
|
||||
cannot (for example a directory owned by another user).
|
||||
4. **Code.** Clone the repository into `/opt/hermeven`, then `npm ci`. (The dev dependencies are
|
||||
needed: the bridge runs through `tsx`.)
|
||||
5. **Configuration.** Copy `deploy/bridge.env.example` to `/etc/hermeven/bridge.env`, fill it
|
||||
|
||||
@@ -0,0 +1,74 @@
|
||||
# Handoff for Cody, Round 4
|
||||
|
||||
From: Claude (implementation). Date: 2026-11-18.
|
||||
|
||||
**Not reviewed.** Cody's Round 3 verdict applies to `e1c02d5` only. Whether CODY-003 and CODY-006
|
||||
are now closed 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 3 | `e1c02d52661987df7caaec9bd132855df90cb814` |
|
||||
| `main` | `0c9dcd864f16782097471e5bbf57cbd701c26616` (unchanged; nothing merged) |
|
||||
| New head for Round 4 | the tip of `cody/slice-1-review` after this push; exact SHA in the push report |
|
||||
|
||||
## CODY-003: request identity durable before submission
|
||||
|
||||
| Required correction | What was done |
|
||||
|---|---|
|
||||
| 1. Storage success/failure explicit at the DevicePort boundary | `storageSet` returns `Promise<boolean>`; `storageGet` returns `{ ok: true, value } \| { ok: false }` (`device/port.ts`). All three implementations updated. |
|
||||
| 2. Never submit until persistence is positively confirmed | `Controller.submit()` returns without contacting the bridge unless `setActiveRequest()` resolved `true`. The controller tracks the last id the host confirmed (`confirmedActive`), so an unconfirmed id is written again on the next attempt instead of being assumed stored. |
|
||||
| 3. On timeout or failure, remain safely unsent and show a retryable state | New `not_saved` event: phase `disconnected`, reason `storage`, resend allowed. The pending question is kept in memory. |
|
||||
| 4. Same immutable request id across deliberate retries | The retry is the existing `resubmit` effect with the original request id. |
|
||||
| 5. A caller timeout is not evidence the write succeeded | `EvenDevice.storageSet` returns `true` only for a host `true` received before the timeout. |
|
||||
|
||||
Beyond the letter of the finding, because it is the same failure on the read side: storage that
|
||||
cannot be read at start is reported as unknown rather than as "not paired", and pairing over it is
|
||||
refused. A pairing the phone cannot save is revoked on the bridge instead of living in memory.
|
||||
|
||||
## CODY-006: pre-existing state directories
|
||||
|
||||
| Required correction | What was done |
|
||||
|---|---|
|
||||
| 1. Enforce 0700 even when the directory exists | `secureStateDir()` in `db.ts` runs on every open, before anything is created inside. |
|
||||
| 2. Clear operator-facing error if it cannot be secured | `StateDirectoryError` names the directory, the required mode and the remedy; `main.ts` prints it as "Cannot start: ...". |
|
||||
| 3. Deployment instructions create or chmod explicitly | `docs/deploy-droplet.md` uses `install -d -m 0700 -o hermeven -g hermeven /var/lib/hermeven`. |
|
||||
| 4. Database, WAL, SHM stay 0600 | Unchanged, and re-asserted in the new tests. |
|
||||
|
||||
## Checks
|
||||
|
||||
| Check | Result |
|
||||
|---|---|
|
||||
| `npm run typecheck` | exit 0 |
|
||||
| `npm test` | 194 passed, 0 failed (was 182) |
|
||||
| `npm run client:build` | built |
|
||||
| `npm run test:real-stt` | 11 passed, 0 failed (all 11 existing tests) |
|
||||
| `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. The proofs are listed in `docs/test-evidence.md` under "Round 4".
|
||||
|
||||
## The eight resolved findings
|
||||
|
||||
Not touched in substance. Their regression tests are unchanged and passing, apart from one
|
||||
assertion in the CODY-002 queue test that now expects the explicit `{ ok: false }` read result.
|
||||
|
||||
## Things the author is unsure about
|
||||
|
||||
- **Whether the Even phone app confirms `setLocalStorage` promptly, or at all.** The simulator's
|
||||
host does. If the phone's does not, this gate stops every question. That would be the correct
|
||||
failure under this finding, but it would make the app unusable, and it can only be learned on a
|
||||
device.
|
||||
- While a host storage call is stuck, HUD updates queued behind it are not drawn (a consequence of
|
||||
CODY-002's strict serialisation). The "could not save" message therefore appears only once the
|
||||
host answers again.
|
||||
- `secureStateDir` will set any directory it is pointed at to 0700. Pointing the database into a
|
||||
directory shared with other software would lock that software out.
|
||||
- The refusal test relies on `/tmp` being owned by another user; where it is not, the test reports
|
||||
"NOT RUN" instead of passing.
|
||||
|
||||
## Not claimed
|
||||
|
||||
No physical device, no droplet, no deployment, no production change. Nothing merged to `main`.
|
||||
+5
-1
@@ -36,7 +36,8 @@ devices. Not reviewed by anyone but its author yet; see `docs/handoff/`.
|
||||
| Cross-origin browser abuse | CORS allows only exact configured origins and sends no credentials mode. CORS is not treated as authentication: every route still needs the bearer credential. | yes |
|
||||
| Secrets or content in logs | Logs carry ids, states, codes and timings. Request logging is off, a redaction list backs it up, and Hermes's own diagnostic text is never relayed or logged. | yes |
|
||||
| Substituted speech-model files | The model is pinned to a commit id with a SHA-256 for every file. Files are fetched ahead of time and verified; the bridge re-verifies on every load, never downloads at run time, and reads from a directory that can be read-only. There is no unpinned mode. | yes, including with no network at all |
|
||||
| State files readable by other users | The database is created owner-only before SQLite opens it (so its WAL and SHM files inherit that), in a 0700 directory; the systemd unit sets `UMask=0077`. | yes, under umask 0022 |
|
||||
| State files readable by other users | The directory holding the database is set to 0700 at every start, whether it was just created or already existed, and the bridge refuses to start if it cannot be. The database is created owner-only before SQLite opens it (so its WAL and SHM files inherit that); the systemd unit sets `UMask=0077`. | yes, under umask 0022, for new and pre-existing directories |
|
||||
| A running turn forgotten by the app | The request id is stored on the phone before anything is sent, and the request is not sent until the phone has confirmed the write. A write that times out or is refused holds the request back, unsent, for a retry under the same id. | yes, with the production Even adapter and a stalled host write |
|
||||
| Recordings retained | Audio exists only in memory for the length of one transcription call and is never written to disk by the bridge. | by construction; not independently audited |
|
||||
| Agent approves its own privileged action | The bridge never calls Hermes's approval endpoint. | yes |
|
||||
| Markup injection from an agent answer into the phone page | The page is built with `textContent` only. | by construction |
|
||||
@@ -71,6 +72,9 @@ Stated so they are not mistaken for protections.
|
||||
4. **In the simulator, raw audio frames are echoed to the WebView console.** Whether the phone
|
||||
does the same is unknown and is on the device checklist. If it does, recordings would be
|
||||
visible to whoever can read that console.
|
||||
4a. **The state directory must be the bridge's own.** Because it is forced to 0700, pointing
|
||||
`HERMEVEN_DB_PATH` into a directory shared with other software will lock that software out;
|
||||
a directory owned by another user is refused.
|
||||
5. **TLS is not terminated by the bridge.** A reverse proxy or private network must provide it. A
|
||||
misconfigured proxy could expose plain HTTP.
|
||||
6. **Rate limits are in memory** and reset on restart. Behind a proxy, per-address limits are only
|
||||
|
||||
@@ -312,3 +312,64 @@ This was not a droplet. `deploy/` and `docs/deploy-droplet.md` remain unrun.
|
||||
|
||||
Unchanged from the list above: no physical G2, no audio from the glasses, no real model or tools
|
||||
behind Hermes, no approval prompt from a real Hermes, no droplet, no HTTPS termination.
|
||||
|
||||
## Round 4: after Cody's Round 3 review (2026-11-18)
|
||||
|
||||
Cody reviewed `e1c02d5`: eight findings resolved, CODY-003 and CODY-006 still open. This section
|
||||
records what was run after correcting those two.
|
||||
|
||||
```
|
||||
$ npm run typecheck exit 0
|
||||
$ npm test Test Files 11 passed (11) Tests 194 passed (194) (3 consecutive runs)
|
||||
$ npm run client:build built
|
||||
$ npm run test:real-stt Tests 11 passed (11) (all 11 existing tests, including the no-network run)
|
||||
$ npm run test:real-hermes Tests 9 passed (9)
|
||||
$ npm run test:simulator Tests 6 passed (6) (3 consecutive runs)
|
||||
$ git diff --check clean
|
||||
```
|
||||
|
||||
No check was omitted.
|
||||
|
||||
### CODY-003: request identity durable before submission
|
||||
|
||||
`tests/integration/durableRequestId.test.ts` uses the production `EvenDevice` adapter with a
|
||||
stand-in Even host whose `setLocalStorage` completes only when the test releases it. The bridge
|
||||
is real; Hermes is the test fake.
|
||||
|
||||
| Scenario | Result |
|
||||
|---|---|
|
||||
| Host write stalled past the adapter timeout: zero `POST /v1/turns`, no turn on the bridge, no Hermes run, the durable copy does not hold the id; a retry while still stalled is held back again under the same id | pass |
|
||||
| Host completes the write: the id becomes durable and that alone sends nothing. Deliberate retry: admitted, every reply dropped. Page restart: re-attached under the same request id, exactly one Hermes run for it, and no HUD text after admission says "not sent" | pass |
|
||||
| Same sequence with a hanging agent, restart, then double tap: Hermes is asked to stop and the turn settles as cancelled | pass |
|
||||
| Cancel while still held back for storage: nothing is sent, nothing exists on the bridge | pass |
|
||||
| Host answers the write with `false`: held back; succeeds on retry once the host accepts | pass |
|
||||
| Page dies during the stall and the host writes late: the next start finds no such turn on the bridge and says so | pass |
|
||||
| Storage unreadable at start: not treated as "not paired"; pairing over it is refused and the code is not spent | pass |
|
||||
| Pairing that the phone cannot save: revoked on the bridge, not kept in memory | pass |
|
||||
| Adapter unit test (fake timers): only a timely `true` is success; timeout and `false` are "not confirmed"; a stalled read is "unknown", not "empty" | pass |
|
||||
|
||||
In the simulator, the real SDK host answered storage writes with a confirmation, so questions
|
||||
were sent normally (the simulator suite would otherwise fail). **Whether the Even phone app
|
||||
confirms `setLocalStorage` the same way, and how quickly, is unknown until it runs on a phone.**
|
||||
If the phone never confirms a write, no question can be sent; the HUD would say "Could not save
|
||||
your request on the phone".
|
||||
|
||||
One consequence worth knowing: host calls are sent strictly one at a time, so while a storage
|
||||
write is stuck, HUD updates queued behind it are not drawn until it completes.
|
||||
|
||||
### CODY-006: state directory permissions
|
||||
|
||||
`services/bridge/test/units.test.ts`:
|
||||
|
||||
| Scenario | Result |
|
||||
|---|---|
|
||||
| Child process under umask 0022, state directory pre-created at 0755: after opening the database and creating WAL and SHM, directory 0700, database, WAL and SHM 0600 | pass |
|
||||
| Pre-existing directories at 0750, 0777, 0711 and 0701 all end at exactly 0700 | pass |
|
||||
| A directory that cannot be secured (`/tmp`, owned by another user): `StateDirectoryError` naming the directory, the required mode and the fix; no file created; the directory left unchanged | pass |
|
||||
| A path whose parent is a file: refused | pass |
|
||||
| Retained: new directory under umask 0022, and the check that no state file is ever group- or world-accessible during creation | pass |
|
||||
|
||||
### Did the new tests have teeth?
|
||||
|
||||
Eight ways of removing these two fixes were tried against the default suite; all eight were
|
||||
caught (between 1 and 6 failing tests each).
|
||||
|
||||
Reference in New Issue
Block a user