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:
Dan
2026-11-18 20:29:05 -08:00
co-authored by Claude Fable 5.2
parent e1c02d5266
commit 1507cea077
19 changed files with 759 additions and 45 deletions
+61
View File
@@ -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).