Skip to content

Commit 1089e7c

Browse files
committed
fix(android): restore all lifted wire fields through the capture rewrap (#1285 review)
normalizeError hoists hint, diagnosticId, logPath, retriable, and supportedOn out of details (ADR 0010); the capture rewrap restored only diagnosticId/logPath, so a transient-classified install rejection (e.g. connection_dropped) lost its structured retriable signal on the public daemon error. liftedDiagnosticIdentity is generalized to liftedWireFields covering the complete hoisted set (hint stays owned by the capture hint selector). Public route regression: a retriable provider install rejection keeps error.retriable === true on the daemon snapshot response.
1 parent dba7393 commit 1089e7c

2 files changed

Lines changed: 50 additions & 8 deletions

File tree

‎src/daemon/__tests__/request-router-android-snapshot-helper.test.ts‎

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,3 +82,41 @@ test('snapshot reports a device-side install failure when the provider install r
8282
expect(response.error.hint).not.toMatch(/pnpm build:android/);
8383
expect(response.error.details?.androidSnapshotHelperInstallFailure).toBe(true);
8484
});
85+
86+
// ADR 0010 wire contract: a transient-classified install rejection (here the
87+
// funnel's `connection_dropped` family) must keep its structured `retriable`
88+
// signal through the capture rewrap onto the public daemon error.
89+
test('snapshot keeps the transient retry signal when the provider install rejection is retriable', async () => {
90+
const sessionStore = makeAndroidSessionStore(
91+
'agent-device-request-router-snapshot-helper-install-transient-test',
92+
);
93+
const provider: AndroidAdbProvider = {
94+
exec: async () => ({ exitCode: 0, stdout: '', stderr: '' }),
95+
install: async () => {
96+
throw new AppError('COMMAND_FAILED', 'Failed to install Android snapshot helper', {
97+
stderr: 'adb: transport error while pushing helper.apk',
98+
stdout: '',
99+
exitCode: 1,
100+
processExitError: true,
101+
});
102+
},
103+
snapshotHelperArtifact: ANDROID_SNAPSHOT_HELPER_FIXTURE_ARTIFACT,
104+
};
105+
const handler = makeHandler(sessionStore, () => provider);
106+
107+
const response = await handler({
108+
token: 'token',
109+
session: 'default',
110+
command: 'snapshot',
111+
positionals: [],
112+
flags: {},
113+
});
114+
115+
expect(response.ok).toBe(false);
116+
if (response.ok) throw new Error('Expected snapshot to fail');
117+
expect(response.error.message).toMatch(/Android snapshot helper failed/);
118+
expect(response.error.hint).toMatch(/connection dropped/);
119+
expect(response.error.hint).toMatch(/device-side install failure/);
120+
expect(response.error.retriable).toBe(true);
121+
expect(response.error.details?.androidSnapshotHelperInstallFailure).toBe(true);
122+
});

‎src/platforms/android/snapshot.ts‎

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -474,7 +474,7 @@ function androidSnapshotHelperCaptureError(error: unknown, reason: string): AppE
474474
`Android snapshot helper failed: ${reason}`,
475475
{
476476
...normalized.details,
477-
...liftedDiagnosticIdentity(normalized),
477+
...liftedWireFields(normalized),
478478
androidSnapshotHelperFailureReason: reason,
479479
hint: androidSnapshotHelperCaptureHint(normalized),
480480
},
@@ -503,13 +503,17 @@ function androidSnapshotHelperCaptureHint(normalized: NormalizedError): string {
503503
);
504504
}
505505

506-
// normalizeError lifts these out of details (ADR 0010); a rewrap must put them
507-
// back so the upstream diagnostic identity survives.
508-
function liftedDiagnosticIdentity(normalized: NormalizedError): Record<string, string> {
509-
const identity: Record<string, string> = {};
510-
if (normalized.diagnosticId !== undefined) identity.diagnosticId = normalized.diagnosticId;
511-
if (normalized.logPath !== undefined) identity.logPath = normalized.logPath;
512-
return identity;
506+
// normalizeError hoists these wire-contract fields out of details (ADR 0010;
507+
// the complete set stripDiagnosticMeta removes, minus hint, which
508+
// androidSnapshotHelperCaptureHint owns). A rewrap must put every one back so
509+
// upstream diagnostics and typed signals like `retriable` survive.
510+
function liftedWireFields(normalized: NormalizedError): Record<string, string | boolean> {
511+
const fields: Record<string, string | boolean> = {};
512+
if (normalized.diagnosticId !== undefined) fields.diagnosticId = normalized.diagnosticId;
513+
if (normalized.logPath !== undefined) fields.logPath = normalized.logPath;
514+
if (normalized.retriable !== undefined) fields.retriable = normalized.retriable;
515+
if (normalized.supportedOn !== undefined) fields.supportedOn = normalized.supportedOn;
516+
return fields;
513517
}
514518

515519
function isKilledHelperInstrumentationFailure(error: {

0 commit comments

Comments
 (0)