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>
This commit is contained in:
Dan
2026-11-18 19:49:14 -08:00
co-authored by Claude Fable 5.2
parent 3d5691dfa3
commit e1c02d5266
43 changed files with 2104 additions and 227 deletions
+29 -3
View File
@@ -329,11 +329,37 @@ describe('pairing, restore and conversations', () => {
const s = ready();
const step = reduce(s, { type: 'new_conversation' });
expect(step.state.conversationId).toBeNull();
expect(step.effects).toEqual([{ type: 'create_conversation', generation: step.state.generation }]);
const stale = reduce(step.state, { type: 'conversation_created', generation: s.generation, conversationId: 'old' });
expect(step.state.creatingConversation).toBe(true);
expect(step.effects).toEqual([{ type: 'create_conversation', epoch: step.state.conversationEpoch }]);
const stale = reduce(step.state, { type: 'conversation_created', epoch: s.conversationEpoch, conversationId: 'old' });
expect(stale.state.conversationId).toBeNull();
const fresh = reduce(step.state, { type: 'conversation_created', generation: step.state.generation, conversationId: 'new' });
const fresh = reduce(step.state, { type: 'conversation_created', epoch: step.state.conversationEpoch, conversationId: 'new' });
expect(fresh.state.conversationId).toBe('new');
expect(fresh.state.creatingConversation).toBe(false);
});
it('a second "new conversation" while one is being created starts nothing (CODY-009)', () => {
const first = reduce(ready(), { type: 'new_conversation' });
const second = reduce(first.state, { type: 'new_conversation' });
expect(second.state).toBe(first.state);
expect(second.effects).toEqual([]);
});
it('the conversation result is accepted even after a question has started, because it is keyed to the conversation, not the turn (CODY-009)', () => {
const created = reduce(ready(), { type: 'new_conversation' });
const asking = reduce(created.state, { type: 'submit_text', freshId: ID1, text: 'hi' });
expect(asking.state.generation).toBeGreaterThan(created.state.generation);
const done = reduce(asking.state, { type: 'conversation_created', epoch: created.state.conversationEpoch, conversationId: 'new' });
expect(done.state.conversationId).toBe('new');
expect(done.state.phase).toBe('thinking');
});
it('a conversation result from before a re-pair or a later reset is dropped', () => {
const created = reduce(ready(), { type: 'new_conversation' });
const repaired = reduce(created.state, { type: 'init', paired: true, conversationId: null, captureMaxSeconds: 30, resumeRequestId: null });
expect(reduce(repaired.state, { type: 'conversation_created', epoch: created.state.conversationEpoch, conversationId: 'x' }).state).toBe(repaired.state);
const failedLate = reduce(repaired.state, { type: 'conversation_failed', epoch: created.state.conversationEpoch, error: { code: 'x', hud: 'x', retryable: false } });
expect(failedLate.state).toBe(repaired.state);
});
it('unpairing while listening closes the microphone', () => {