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
+37 -1
View File
@@ -215,7 +215,7 @@ describe('CODY-002: host calls stay serialised and a late microphone start ends
await tick();
expect(host.calls.map((x) => x.name)).toEqual(['get']);
await vi.advanceTimersByTimeAsync(CALL_TIMEOUT_MS + 1);
expect(await a).toBe(''); // bounded for the caller
expect(await a).toEqual({ ok: false }); // bounded for the caller, and reported as unknown
await b;
await c;
expect(host.calls.map((x) => x.name)).toEqual(['get']); // still only the stuck call at the host
@@ -227,4 +227,40 @@ describe('CODY-002: host calls stay serialised and a late microphone start ends
expect(host.calls.map((x) => x.name)).toEqual(['get', 'set', 'exit']);
expect(host.maxInFlight()).toBe(1);
});
it('storage: only a timely `true` from the host is success; a timeout or `false` is "not confirmed", a stalled read is "unknown"', async () => {
const host = fakeHost();
const device = new EvenDevice(host.bridge as never);
const confirmed = device.storageSet('k', 'v');
await tick();
host.pending()[0]!.resolve(true);
expect(await confirmed).toBe(true);
const refused = device.storageSet('k', 'v');
await tick();
host.pending()[0]!.resolve(false);
expect(await refused).toBe(false);
const stalled = device.storageSet('k', 'v');
await vi.advanceTimersByTimeAsync(CALL_TIMEOUT_MS + 1);
expect(await stalled).toBe(false); // the wait ran out; that is not a successful write
host.pending()[0]!.resolve(true); // ...even though the host completes it later
await tick();
const read = device.storageGet('k');
await tick();
host.pending()[0]!.resolve('value');
expect(await read).toEqual({ ok: true, value: 'value' });
const empty = device.storageGet('k');
await tick();
host.pending()[0]!.resolve('');
expect(await empty).toEqual({ ok: true, value: '' });
const unknown = device.storageGet('k');
await vi.advanceTimersByTimeAsync(CALL_TIMEOUT_MS + 1);
expect(await unknown).toEqual({ ok: false });
expect(host.maxInFlight()).toBe(1);
});
});