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:
@@ -52,8 +52,13 @@ export interface AppState {
|
||||
error: HudError | null;
|
||||
/** In DISCONNECTED: the request never reached the bridge, so resending it is safe. */
|
||||
canResend: boolean;
|
||||
/** Why we are disconnected: the bridge link, or the glasses themselves. */
|
||||
disconnectedFrom: 'bridge' | 'glasses' | null;
|
||||
/**
|
||||
* Why we are stopped: the bridge link, the glasses themselves, or the phone's app storage
|
||||
* (the request id could not be saved, so the request was deliberately not sent).
|
||||
*/
|
||||
disconnectedFrom: 'bridge' | 'glasses' | 'storage' | null;
|
||||
/** App storage could not be read at start; saved pairing state is unknown. */
|
||||
storageFault: boolean;
|
||||
notice: string | null;
|
||||
}
|
||||
|
||||
@@ -72,11 +77,12 @@ export const initialState: AppState = {
|
||||
error: null,
|
||||
canResend: false,
|
||||
disconnectedFrom: null,
|
||||
storageFault: false,
|
||||
notice: null,
|
||||
};
|
||||
|
||||
export type AppEvent =
|
||||
| { type: 'init'; paired: boolean; conversationId: string | null; captureMaxSeconds: number; resumeRequestId: string | null }
|
||||
| { type: 'init'; paired: boolean; conversationId: string | null; captureMaxSeconds: number; resumeRequestId: string | null; storageFault?: boolean }
|
||||
| { type: 'unpaired' }
|
||||
/** Semantic actions. `freshId` is a new UUID supplied by the caller in case a turn starts. */
|
||||
| { type: 'activate'; freshId: string }
|
||||
@@ -95,6 +101,8 @@ export type AppEvent =
|
||||
| { type: 'turn_update'; generation: number; result: TurnResult; pages: string[] | null }
|
||||
| { type: 'turn_rejected'; generation: number; error: HudError }
|
||||
| { type: 'network_lost'; generation: number; stage: 'submit' | 'poll' }
|
||||
/** The request id could not be stored, so the request was held back. Nothing was sent. */
|
||||
| { type: 'not_saved'; generation: number }
|
||||
| { type: 'network_restored'; generation: number }
|
||||
| { type: 'glasses_status'; connected: boolean }
|
||||
| { type: 'app_exit' };
|
||||
@@ -160,6 +168,7 @@ export function reduce(state: AppState, event: AppEvent): Step {
|
||||
captureMaxSeconds: event.captureMaxSeconds,
|
||||
conversationId: event.conversationId,
|
||||
conversationEpoch: state.conversationEpoch + 1,
|
||||
storageFault: event.storageFault === true,
|
||||
};
|
||||
if (!event.paired) return same({ ...base, phase: 'unpaired' });
|
||||
if (event.resumeRequestId) {
|
||||
@@ -352,6 +361,13 @@ export function reduce(state: AppState, event: AppEvent): Step {
|
||||
return same({ ...state, phase: 'disconnected', disconnectedFrom: 'bridge', canResend: event.stage === 'submit' });
|
||||
}
|
||||
|
||||
case 'not_saved': {
|
||||
if (event.generation !== state.generation) return same(state);
|
||||
if (!IN_FLIGHT.has(state.phase) && state.phase !== 'disconnected') return same(state);
|
||||
// Same request id is kept, so a retry is the same request, not a new one.
|
||||
return same({ ...state, phase: 'disconnected', disconnectedFrom: 'storage', canResend: true });
|
||||
}
|
||||
|
||||
case 'network_restored': {
|
||||
if (event.generation !== state.generation || state.phase !== 'disconnected' || state.disconnectedFrom !== 'bridge') {
|
||||
return same(state);
|
||||
|
||||
Reference in New Issue
Block a user