Skip to content

Commit 54e6cea

Browse files
committed
fix(apple-runner): restart without resending a command written then lost (#3082)
* fix(apple-runner): name the lost reply when status cannot place a lost command A command whose reply was lost and whose status probe answers notAccepted (a restarted runner's empty journal) or an unnamed state now fails with details.reason runner_reply_lost beside dispatched unknown, so a caller keys on the typed reason instead of the message before it observes the screen. Tests (fake runner server through runAppleRunnerCommand and the recovery module): - runner-recovery-wiring: press and fill (runner tap and type) accept the command, drop the connection, status answers notAccepted: one dispatched command, error dispatched unknown with reason runner_reply_lost, the session is invalidated, and the next command gets a runner. Mutation: delete `reason: RUNNER_REPLY_LOST_REASON` from the unknown-state error -> both rows fail. - runner-recovery-wiring: a snapshot whose reply is dropped is resent and succeeds. Mutation: declare snapshot with DEFAULT_TRAITS (not read-only) -> fails (the lost read goes to status recovery and is not resent). - runner-command-recovery: notAccepted yields reason runner_reply_lost and dispatched unknown. Mutation: same deletion as above -> fails. * fix(apple-runner): restart without resending a command written then lost A connect-shaped failure keeps its restart, but the command is sent again on the restarted runner only with proof the first send could not have run it: the attempt provably wrote nothing (a connect refused before the write, dispatched no), the readiness preflight gave up before the write, or the command is read-only by its runner trait. A mutating command whose first attempt may have written it now fails with reason runner_reply_lost and dispatched unknown after the restart; a restarted runner's journal is empty, so no status answer can prove the first send did not run. A read-only command's restart failure discloses no: a read has no side effect to repeat. dispatch-disclosure.json: ios-runner.transport.written-then-lost keeps unknown with a trigger that says the command is not resent; ios-runner.transport.read-only-written-then-lost is new and discloses no. Tests (runner-lifecycle-dispatch-disclosure, real connect loop over a stubbed fetch and simctl curl exit 28, restart succeeds): - written-then-lost: tap restarts the runner, is not sent on the restarted runner, fails unknown with reason runner_reply_lost. Mutation: make canResendAfterRestart return true -> fails (the tap is replayed and the request succeeds). - read-only-written-then-lost: snapshot is sent again on the restarted runner and its failure discloses no. Mutations: drop the read-only term from canResendAfterRestart -> fails (no resend); drop the read-only branch of discloseRestartDispatch -> fails (unknown). runner-command-retry: four mutating-restart fixtures now carry the proof a real refused connect stamps (dispatched no); without it they would test the removed replay. * test(apple): share the unwritten connect refusal fixture to keep the retry test file within its size ratchet * fix(apple-runner): report the restart transport fact for a read, not no The restart path disclosed `no` for a read-only command whose first send may have run, while the status-recovery path discloses `unknown` for the same read (read_only_completed_without_retained_response, and the notAccepted/unknown-state fallthrough). Both runner paths now report the transport fact: a first attempt that may have written the command is `unknown`, read or mutation. The read-only `no` has one owner, the daemon router seam (request-dispatch-disclosure.ts), which keys it on the registry's recordingEffect `observes-app` for every producer (daemon.read-only-command). A second copy keyed on the runner's own read-only trait reconstructed that rule from a different source of truth, and the two runner paths disagreed. The recycle-budget refusal on the restart path also stops deriving `no` from the read-only trait and uses only whether the first attempt was provably unwritten. The runner still resends a read on the restarted runner (canResendAfterRestart); only the disclosure changes. dispatch-disclosure.json: - ios-runner.transport.read-only-written-then-lost: now `unknown`; the trigger names the router rule that turns it into `no` for the caller. - ios-runner.status.read-only-completed-without-retained-reply: new, `unknown`, driven through the real connect loop and recovery module. It pins the status-recovery read to the same value as the restart read. Mutations: - put back `if (isReadOnlyRunnerCommand(evidence.command)) return discloseDispatch(error, 'no')` in discloseRestartDispatch -> read-only-written-then-lost fails. - set `dispatched: 'no'` on read_only_completed_without_retained_response -> status.read-only-completed-without-retained-reply fails. * test(apple-runner): drive a real runner death through the fake runner runner-recovery-wiring: the notAccepted mutation test no longer scripts a second `ok` for the mutation. Nothing consumed it, and it suggested that a resend was expected. Its comment now says what the test models: status answers notAccepted, the way a runner whose journal did not survive a restart would. The path is status recovery, not the daemon's restart. The fake runner server gains an `exit` reply: it hangs up and stops listening, like a runner process that died mid-command. Before this, a test could only hang up on one request while the same server stayed up. Two new tests use a second server as the restarted runner: - press/fill (runner tap/type): the runner dies on the command. The mutation is sent once, is not sent to the restarted runner, fails with dispatched unknown, and the dead session is invalidated. A readText on the next request is served by the restarted runner. Mutation: declare tap and type with READ_ONLY_TRAITS (the resend trait) -> both rows fail. - get (runner readText): the runner dies mid-read. The connect loop gives up with a possibly-written POST (simctl curl exit 28), the daemon restarts the runner (runner_connect_failed_before_command_send), and the read is resent once and succeeds. Mutation: reduce canResendAfterRestart to `evidence.firstAttemptUnwritten` -> fails (no resend). With the real transport, a mutating command never reaches restartSessionAndRunCommand with a possibly-written first attempt. Mutations are sent by sendRunnerCommandOnce, and only the connect loop (waitForRunner, used for reads and the readiness preflight) stamps runner_connect_refused. So the mutating arm of canResendAfterRestart is covered only by the mocked lifecycle driver (ios-runner.transport.written-then-lost). A dying runner sends a mutation to status recovery, and a failed status probe rethrows the transport error without a runner_reply_lost reason. * fix(apple-runner): name the lost reply when the status probe fails A runner that dies mid-mutation drops the reply, and the status probe that follows fails. The error that reaches the caller was then a bare transport error (`fetch failed`, dispatched unknown), with no typed reason. #3074 requires a reason that names the lost reply, so this path now builds an error with reason runner_reply_lost (the name the restart arm already uses) and recovery status_probe_failed. The error keeps the transport message and details, and the transport error as cause. The session is still invalidated, and the command is still not resent. ADR 0011 gap list: the row ios-runner.transport.written-then-lost proves the rule behind canResendAfterRestart's mutating arm, not a production route. Over the real transport the arm cannot be reached, because mutations go through sendRunnerCommandOnce and only the connect loop raises the restart trigger. Tests: - runner-command-recovery: a failing status probe now asserts reason runner_reply_lost, recovery status_probe_failed, dispatched unknown, and the transport error as cause. - runner-recovery-wiring: press/fill whose runner dies mid-command (real fake-runner transport) now also asserts reason runner_reply_lost. Mutation: drop `reason: RUNNER_REPLY_LOST_REASON` from buildStatusProbeFailedError -> all three fail. * test(apple-runner): hang up on every read attempt without counting the connect loop The read-only lost-response driver scripted 20 hang-ups and a 400 ms timeout. That count depended on the connect loop's retry cadence (RUNNER_CONNECT_ATTEMPT_INTERVAL_MS): with a faster cadence the queue runs out, and the fake answers the next attempt with `ok`. The fake runner server now has a `hangUpAlways` reply that is never consumed, so the read is refused until the loop gives up, however often it retries. The timeout now only bounds how long the loop runs. Mutation: set RUNNER_CONNECT_ATTEMPT_INTERVAL_MS to 10 or 50 (with a 1 ms retry base delay) -> ios-runner.status.read-only-completed-without-retained-reply still passes. * test(apple-runner): pick the fake runner's next reply in one helper The request handler of the fake runner server went over the fallow complexity threshold after hangUpAlways was added. The choice of the next scripted reply is now in takeScriptedResponse. Behavior is unchanged: the apple-runner suite passes (768 tests). * refactor(apple-runner): gate the restart resend at the connect-failure call site A mutation never reaches the connect loop, so the no-resend arm after a restart had no production route. The call site now restarts only when the first attempt provably wrote nothing or the command is read-only, and the arm and its error builder are gone. The written-then-lost row is driven through a fake runner that dies mid-command. A failed status probe keeps a transport reason under transportReason. * test(apple-runner): name runner_reply_lost in the lost-reply test titles * test(apple-runner): the runner read-only set matches the registry's observes-app commands * fix(apple-runner): decide the restart resend in the connect-failure classifier shouldRestartRunnerBeforeCommandSend now takes the command and owns the write-proof rule: a connect-loop failure restarts and resends only when no attempt could have written the command, or the command is read-only. An exit-28 POST that carries dispatched unknown no longer restarts a mutation, whatever call site asks. The call-site guard in executeRunnerCommandAttempt is gone. * refactor(apple-runner): carry the first attempt's dispatch disclosure through the restart restartSessionAndRunCommand takes firstAttemptDispatched: DispatchDisclosure instead of a boolean that three ternaries decoded back into no or unknown. resolveFirstAttemptDispatch computes it once beside isRunnerCommandProvablyUnwritten, and the restart rule reads the same answer. The readiness-preflight call site passes no. * refactor(apple-runner): build every lost-reply failure in one place with one reason Status recovery verdicts now carry either the runner's own answer or the facts of a lost reply. applyRunnerTransportRecovery turns a lost reply into one buildLostReplyError for a mutation, so runner_reply_lost is set on every lost-reply verdict (completed without a retained reply, still in flight, unknown or missing lifecycle, status probe failed, status unavailable) and the transport's reason stays under transportReason. A read keeps its transport error, which the read-only resend loop resends, so it never carries the reason. The four hand-built copies are gone. * fix(apple-runner): key a lost reply on its typed reason, never on transport text * docs(adr): name the lost-reply dispatch-disclosure rows in ADR 0011 * test(apple-runner): pair keyboardReturn with the keyboard enter request that issues it * test(apple-runner): pin the lost-reply branch in the connect-loop mutation test
1 parent 5e520b5 commit 54e6cea

14 files changed

Lines changed: 806 additions & 191 deletions

‎contracts/fixtures/dispatch-disclosure.json‎

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,13 @@
256256
{
257257
"id": "ios-runner.transport.written-then-lost",
258258
"producer": "ios-runner",
259-
"trigger": "a connect attempt posted the command and then timed out (fetch deadline, simctl curl exit 28); the failure keeps the runner_connect_refused restart verdict, and the restart that replays it failed",
259+
"trigger": "a mutating command was posted and the runner process died before replying; the status probe fails, the session is invalidated, and the command is not sent again (details.reason runner_reply_lost)",
260+
"dispatched": "unknown"
261+
},
262+
{
263+
"id": "ios-runner.transport.read-only-written-then-lost",
264+
"producer": "ios-runner",
265+
"trigger": "a connect attempt posted a read-only command and then timed out (fetch deadline, simctl curl exit 28); the runner is restarted and the read is sent again, and the resend failed; the first send may have run, so the runner reports unknown, and the daemon's read-only rule (daemon.read-only-command) reports no to the caller",
260266
"dispatched": "unknown"
261267
},
262268
{
@@ -289,6 +295,12 @@
289295
"trigger": "transport lost; status probe reports lifecycleState completed without a readable retained reply",
290296
"dispatched": "unknown"
291297
},
298+
{
299+
"id": "ios-runner.status.read-only-completed-without-retained-reply",
300+
"producer": "ios-runner",
301+
"trigger": "transport lost on a read-only command; status probe reports lifecycleState completed without a readable retained reply; the runner reports unknown, and the daemon's read-only rule (daemon.read-only-command) reports no to the caller",
302+
"dispatched": "unknown"
303+
},
292304
{
293305
"id": "ios-runner.status.accepted",
294306
"producer": "ios-runner",

‎docs/adr/0011-interaction-guarantee-contract.md‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,18 @@ repeat. A producer that runs several device inputs inside one bound operation
192192
Each row names its driver file by id prefix, and that file drives the real
193193
producer.
194194

195+
The Apple runner does not resend a mutating command whose first send may have
196+
run: a restart resends only a command the first attempt provably did not write,
197+
or a read-only one. A mutation whose reply stays lost (the runner dies
198+
mid-command, or status recovery finds neither a retained result nor a runner
199+
answer) fails with `reason: runner_reply_lost` and `dispatched: unknown` (rows
200+
`ios-runner.transport.written-then-lost`,
201+
`ios-runner.status.completed-without-retained-reply`,
202+
`ios-runner.status.accepted`, `ios-runner.status.started`,
203+
`ios-runner.status.notAccepted`, `ios-runner.status.probe-failed`, and
204+
`ios-runner.status.unavailable`). The `ios-runner.status.failed*` rows carry the
205+
runner's own answer instead. A read keeps its transport error and is resent.
206+
195207
Remaining gaps: a failure before the router's locked scope (session
196208
resolution, lock acquisition, lease and daemon-policy admission) never reaches
197209
the disclosure and carries no `dispatched`. It sends nothing, but a consumer

‎packages/platform-apple/src/runner/__tests__/fake-runner-server.ts‎

Lines changed: 44 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,11 @@ import type { AddressInfo } from 'node:net';
1313
export type FakeRunnerResponse =
1414
| { kind: 'ok'; data: Record<string, unknown> }
1515
| { kind: 'runnerError'; code: string; message: string }
16-
| { kind: 'hangUp' };
16+
| { kind: 'hangUp' }
17+
/** Hangs up on this request and every later one for the command: the entry is never consumed. */
18+
| { kind: 'hangUpAlways' }
19+
/** Hangs up and stops listening, as a runner process that died mid-command. */
20+
| { kind: 'exit' };
1721

1822
export type FakeRunnerRequest = {
1923
command: string;
@@ -44,6 +48,7 @@ export async function startFakeRunnerServer(
4448
: Object.fromEntries(Object.entries(script).map(([key, list]) => [key, [...list]]));
4549
const remaining = sequential ?? [];
4650
const requests: FakeRunnerRequest[] = [];
51+
let stopped: Promise<void> | undefined;
4752
const server = http.createServer((req, res) => {
4853
let raw = '';
4954
req.on('data', (chunk) => {
@@ -53,24 +58,18 @@ export async function startFakeRunnerServer(
5358
const body = parseBody(raw);
5459
requests.push({ command: String(body.command ?? ''), body });
5560
const next = byCommand
56-
? (byCommand[String(body.command ?? '')]?.shift() ?? { kind: 'ok' as const, data: {} })
57-
: remaining.shift();
58-
if (!next) {
59-
res.statusCode = 500;
60-
res.end(JSON.stringify({ ok: false, error: { message: 'fake runner script exhausted' } }));
61-
return;
62-
}
63-
if (next.kind === 'hangUp') {
61+
? (takeScriptedResponse(byCommand[String(body.command ?? '')]) ?? {
62+
kind: 'ok' as const,
63+
data: {},
64+
})
65+
: takeScriptedResponse(remaining);
66+
if (next?.kind === 'exit') {
6467
res.destroy();
68+
stopped ??= new Promise<void>((resolve) => server.close(() => resolve()));
69+
server.closeAllConnections();
6570
return;
6671
}
67-
if (next.kind === 'runnerError') {
68-
res.setHeader('content-type', 'application/json');
69-
res.end(JSON.stringify({ ok: false, error: { code: next.code, message: next.message } }));
70-
return;
71-
}
72-
res.setHeader('content-type', 'application/json');
73-
res.end(JSON.stringify({ ok: true, data: next.data }));
72+
writeFakeRunnerResponse(res, next);
7473
});
7574
});
7675
await new Promise<void>((resolve) => server.listen(0, '127.0.0.1', resolve));
@@ -79,12 +78,41 @@ export async function startFakeRunnerServer(
7978
port,
8079
requests,
8180
close: () =>
81+
stopped ??
8282
new Promise<void>((resolve, reject) =>
8383
server.close((error) => (error ? reject(error) : resolve())),
8484
),
8585
};
8686
}
8787

88+
/** The next scripted reply; a `hangUpAlways` entry stays at the head of its queue. */
89+
function takeScriptedResponse(
90+
queue: FakeRunnerResponse[] | undefined,
91+
): FakeRunnerResponse | undefined {
92+
return queue?.[0]?.kind === 'hangUpAlways' ? queue[0] : queue?.shift();
93+
}
94+
95+
function writeFakeRunnerResponse(
96+
res: http.ServerResponse,
97+
next: Exclude<FakeRunnerResponse, { kind: 'exit' }> | undefined,
98+
): void {
99+
if (!next) {
100+
res.statusCode = 500;
101+
res.end(JSON.stringify({ ok: false, error: { message: 'fake runner script exhausted' } }));
102+
return;
103+
}
104+
if (next.kind === 'hangUp' || next.kind === 'hangUpAlways') {
105+
res.destroy();
106+
return;
107+
}
108+
res.setHeader('content-type', 'application/json');
109+
if (next.kind === 'runnerError') {
110+
res.end(JSON.stringify({ ok: false, error: { code: next.code, message: next.message } }));
111+
return;
112+
}
113+
res.end(JSON.stringify({ ok: true, data: next.data }));
114+
}
115+
88116
function parseBody(raw: string): Record<string, unknown> {
89117
try {
90118
const parsed: unknown = JSON.parse(raw);

‎packages/platform-apple/src/runner/__tests__/runner-command-recovery.test.ts‎

Lines changed: 36 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { IOS_SIMULATOR } from './device-fixtures.ts';
66
import type { ExecResult } from '@agent-device/host-kit/command';
77
import { handleRunnerTransportErrorAfterCommandSend } from '../runner-command-recovery.ts';
88
import type { RunnerCommand } from '../runner-contract.ts';
9+
import { RUNNER_REPLY_LOST_REASON } from '../runner-error-classification.ts';
910
import type { RunnerSession } from '../runner-session.ts';
1011
import {
1112
startFakeRunnerServer,
@@ -122,22 +123,53 @@ test('an unknown lifecycle state invalidates the session and says so', async ()
122123
assert.equal(invalidate.mock.calls[0]?.[1], 'transport_error_after_command_send');
123124
});
124125

125-
test('a failing status probe retains the invalidation and rethrows the transport error', async () => {
126+
test('notAccepted from a restarted runner fails the lost command as unknown, naming the lost reply', async () => {
127+
const { result, invalidate } = await runRecovery({
128+
script: [{ kind: 'ok', data: { lifecycleState: 'notAccepted' } }],
129+
});
130+
131+
await assert.rejects(result, (error: unknown) => {
132+
assert.ok(error instanceof AppError);
133+
assert.equal(error.details?.reason, RUNNER_REPLY_LOST_REASON);
134+
assert.equal(error.details?.dispatched, 'unknown');
135+
return true;
136+
});
137+
assert.equal(invalidate.mock.calls.length, 1);
138+
});
139+
140+
test('a failing status probe retains the invalidation and names the lost reply', async () => {
126141
const { result, invalidate, transportError } = await runRecovery({
127142
script: [{ kind: 'runnerError', code: 'COMMAND_FAILED', message: 'status probe exploded' }],
143+
transportError: new AppError('COMMAND_FAILED', 'socket hang up', { reason: 'socket_reset' }),
128144
});
129145

130-
await assert.rejects(result, (error: unknown) => error === transportError);
146+
await assert.rejects(result, (error: unknown) => {
147+
assert.ok(error instanceof AppError);
148+
assert.notEqual(error.message, transportError.message);
149+
assert.equal(error.details?.transportError, transportError.message);
150+
assert.equal(error.cause, transportError);
151+
assert.equal(error.details?.reason, RUNNER_REPLY_LOST_REASON);
152+
assert.equal(error.details?.transportReason, 'socket_reset');
153+
assert.equal(error.details?.recovery, 'status_probe_failed');
154+
assert.equal(error.details?.dispatched, 'unknown');
155+
return true;
156+
});
131157
assert.equal(invalidate.mock.calls.length, 1);
132158
});
133159

134-
test('a command without an id cannot be probed: invalidate and rethrow', async () => {
160+
test('a command without an id cannot be probed: invalidate and name the lost reply', async () => {
135161
const { result, invalidate, transportError } = await runRecovery({
136162
script: [],
137163
command: { command: 'tap', x: 10, y: 10 } as RunnerCommand,
138164
});
139165

140-
await assert.rejects(result, (error: unknown) => error === transportError);
166+
await assert.rejects(result, (error: unknown) => {
167+
assert.ok(error instanceof AppError);
168+
assert.equal(error.cause, transportError);
169+
assert.equal(error.details?.reason, RUNNER_REPLY_LOST_REASON);
170+
assert.equal(error.details?.recovery, 'status_recovery_unavailable');
171+
return true;
172+
});
141173
assert.equal(invalidate.mock.calls.length, 1);
142174
assert.equal(server?.requests.length, 0);
143175
});

‎packages/platform-apple/src/runner/__tests__/runner-command-retry.test.ts‎

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import {
55
createTestRequestCancellation,
66
makeRunnerSession,
77
runnerConnectFailure,
8+
unwrittenConnectRefusal,
89
} from './runner-session-fixtures.ts';
910
import { AppError } from '@agent-device/kernel/errors';
1011
import { Deadline } from '../host.ts';
@@ -49,6 +50,7 @@ vi.mock('../runner-xctestrun.ts', async () => {
4950

5051
import { prepareIosRunner, runAppleRunnerCommand } from '../runner-client.ts';
5152
import { resetRunnerRecycleLedgerForTests } from '../runner-recycle-ledger.ts';
53+
import { RUNNER_REPLY_LOST_REASON } from '../runner-error-classification.ts';
5254
import type { RunnerXctestrunArtifact } from '../runner-xctestrun.ts';
5355

5456
const requestCancellation = createTestRequestCancellation();
@@ -306,7 +308,7 @@ test('mutating commands restart stale ready sessions when the preflight probe ne
306308

307309
mockEnsureRunnerSession.mockResolvedValueOnce(staleSession).mockResolvedValueOnce(freshSession);
308310
mockExecuteRunnerCommandWithSession
309-
.mockRejectedValueOnce(runnerConnectFailure('runner_connect_refused'))
311+
.mockRejectedValueOnce(unwrittenConnectRefusal())
310312
.mockResolvedValueOnce({ message: 'tapped' });
311313

312314
const result = await runAppleRunnerCommand(IOS_SIMULATOR, { command: 'tap', x: 120, y: 240 });
@@ -329,7 +331,7 @@ test('mutating commands retry startup sessions with stale bundle cleanup', async
329331

330332
mockEnsureRunnerSession.mockResolvedValueOnce(startupSession).mockResolvedValueOnce(freshSession);
331333
mockExecuteRunnerCommandWithSession
332-
.mockRejectedValueOnce(runnerConnectFailure('runner_connect_refused'))
334+
.mockRejectedValueOnce(unwrittenConnectRefusal())
333335
.mockResolvedValueOnce({ message: 'tapped' });
334336

335337
const result = await runAppleRunnerCommand(IOS_SIMULATOR, { command: 'tap', x: 120, y: 240 });
@@ -474,10 +476,9 @@ test('mutating commands keep invalidating when status recovery probe fails', asy
474476
await assert.rejects(
475477
() => runAppleRunnerCommand(IOS_SIMULATOR, { command: 'tap', x: 120, y: 240 }),
476478
(error: unknown) => {
477-
// A failed status probe re-throws the original transport error, not the probe's own.
478479
assert.ok(error instanceof AppError);
479-
assert.equal(error.code, 'COMMAND_FAILED');
480-
assert.equal(error.message, 'fetch failed');
480+
assert.equal(error.details?.reason, RUNNER_REPLY_LOST_REASON);
481+
assert.equal(error.details?.transportError, 'fetch failed');
481482
return true;
482483
},
483484
);
@@ -814,7 +815,7 @@ test('mutating commands invalidate the retry session without replaying again', a
814815

815816
mockEnsureRunnerSession.mockResolvedValueOnce(staleSession).mockResolvedValueOnce(freshSession);
816817
mockExecuteRunnerCommandWithSession
817-
.mockRejectedValueOnce(runnerConnectFailure('runner_connect_refused'))
818+
.mockRejectedValueOnce(unwrittenConnectRefusal())
818819
.mockRejectedValueOnce(new AppError('COMMAND_FAILED', 'fetch failed'))
819820
.mockResolvedValueOnce({ lifecycleState: 'notAccepted' });
820821

@@ -970,10 +971,9 @@ test('sequence invalidates the session when the status probe fails', async () =>
970971
steps: [{ kind: 'tap', x: 1, y: 2 }],
971972
}),
972973
(error: unknown) => {
973-
// A failed status probe re-throws the original transport error, not the probe's own.
974974
assert.ok(error instanceof AppError);
975-
assert.equal(error.code, 'COMMAND_FAILED');
976-
assert.equal(error.message, 'fetch failed');
975+
assert.equal(error.details?.reason, RUNNER_REPLY_LOST_REASON);
976+
assert.equal(error.details?.transportError, 'fetch failed');
977977
return true;
978978
},
979979
);
@@ -1189,10 +1189,9 @@ test('a later command in the same request cannot pay for a second recycle boot',
11891189
const requestId = 'req-restart-cap';
11901190
const staleSession = makeRunnerSession({ port: 8100, state: 'ready' });
11911191
const freshSession = makeRunnerSession({ port: 8101, state: 'starting' });
1192-
11931192
mockEnsureRunnerSession.mockResolvedValueOnce(staleSession).mockResolvedValueOnce(freshSession);
11941193
mockExecuteRunnerCommandWithSession
1195-
.mockRejectedValueOnce(runnerConnectFailure('runner_connect_refused'))
1194+
.mockRejectedValueOnce(unwrittenConnectRefusal())
11961195
.mockResolvedValueOnce({ message: 'tapped' });
11971196

11981197
// First command consumes the request's only recycle via restart-and-replay.

0 commit comments

Comments
 (0)