Skip to content

Commit 225e0bd

Browse files
thymikeeclaude
andcommitted
fix(daemon): drop the unused host from install-from-source and tighten test envs
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
1 parent 7eb7379 commit 225e0bd

6 files changed

Lines changed: 37 additions & 41 deletions

File tree

‎packages/daemon/src/server/http/daemon-session-idle-expiry-scheduling.test.ts‎

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,11 @@ import {
99
WINDOW_MS,
1010
} from '../__tests__/session-idle-expiry-harness.ts';
1111
import { makeIosSession } from '../../__tests__/support/session-factories.ts';
12-
import { IOS_SIMULATOR, bindTestCommandHost } from '@agent-device/test-kit';
12+
import {
13+
IOS_SIMULATOR,
14+
bindTestCommandHost,
15+
createTestHostEnvironment,
16+
} from '@agent-device/test-kit';
1317

1418
bindTestCommandHost();
1519

@@ -46,7 +50,7 @@ test('a session still inside its window survives a sweep that actually ran', asy
4650
const sweeps = createSweepBarrier();
4751

4852
const controller = createSessionIdleExpiry({
49-
env: process.env,
53+
env: createTestHostEnvironment().env,
5054
sessionStore,
5155
idleExpiryMs: WINDOW_MS,
5256
executionLocks: new Map(),
@@ -74,7 +78,7 @@ test('the policy being off arms nothing at all, even for a long-dead session', a
7478
let settleCalls = 0;
7579

7680
const controller = createSessionIdleExpiry({
77-
env: process.env,
81+
env: createTestHostEnvironment().env,
7882
sessionStore,
7983
idleExpiryMs: 0,
8084
executionLocks: new Map(),
@@ -104,7 +108,7 @@ test('a window longer than a timer can express does not sweep a session that is
104108
let sweeps = 0;
105109

106110
const controller = createSessionIdleExpiry({
107-
env: process.env,
111+
env: createTestHostEnvironment().env,
108112
sessionStore,
109113
idleExpiryMs: LONG_WINDOW_MS,
110114
executionLocks: new Map(),
@@ -136,7 +140,7 @@ test('a window longer than a timer can express still expires once the window ela
136140
session.lastActivityAtMs = NOW;
137141

138142
const controller = createSessionIdleExpiry({
139-
env: process.env,
143+
env: createTestHostEnvironment().env,
140144
sessionStore,
141145
idleExpiryMs: LONG_WINDOW_MS,
142146
executionLocks: new Map(),
@@ -172,7 +176,7 @@ test('an expiry waits for the session lock a command of its own holds', async ()
172176
const sweeps = createSweepBarrier();
173177

174178
const controller = createSessionIdleExpiry({
175-
env: process.env,
179+
env: createTestHostEnvironment().env,
176180
sessionStore,
177181
idleExpiryMs: WINDOW_MS,
178182
executionLocks: locks,
@@ -214,7 +218,7 @@ test('an expiry waits for the DEVICE lock a command on another session holds', a
214218
const sweeps = createSweepBarrier();
215219

216220
const controller = createSessionIdleExpiry({
217-
env: process.env,
221+
env: createTestHostEnvironment().env,
218222
sessionStore,
219223
idleExpiryMs: WINDOW_MS,
220224
executionLocks: locks,
@@ -257,7 +261,7 @@ test('a command that re-stamped activity while the expiry queued cancels it', as
257261
let sweepsCompleted = 0;
258262

259263
const controller = createSessionIdleExpiry({
260-
env: process.env,
264+
env: createTestHostEnvironment().env,
261265
sessionStore,
262266
idleExpiryMs: WINDOW_MS,
263267
executionLocks: locks,
@@ -306,7 +310,7 @@ test('a session that moved to another device is fenced by that device, not the s
306310
const sweeps = createSweepBarrier();
307311

308312
const controller = createSessionIdleExpiry({
309-
env: process.env,
313+
env: createTestHostEnvironment().env,
310314
sessionStore,
311315
idleExpiryMs: WINDOW_MS,
312316
executionLocks: locks,
@@ -365,7 +369,7 @@ test('a settle that outlives the budget is caught by the sweep rather than the p
365369
idleClaimedSession(sessionStore);
366370
const sweeps = createSweepBarrier();
367371
const controller = createSessionIdleExpiry({
368-
env: process.env,
372+
env: createTestHostEnvironment().env,
369373
sessionStore,
370374
idleExpiryMs: WINDOW_MS,
371375
executionLocks: new Map(),
@@ -388,7 +392,7 @@ test('a sweep runs inside the composition diagnostics scope it is given', async
388392
const scopes: string[] = [];
389393

390394
const controller = createSessionIdleExpiry({
391-
env: process.env,
395+
env: createTestHostEnvironment().env,
392396
sessionStore,
393397
idleExpiryMs: WINDOW_MS,
394398
executionLocks: new Map(),
@@ -423,7 +427,7 @@ test('a settle that outruns its wait still finishes the release it started', asy
423427

424428
// A window short enough that the retry becomes reachable while the settle is still stuck.
425429
const controller = createSessionIdleExpiry({
426-
env: process.env,
430+
env: createTestHostEnvironment().env,
427431
sessionStore,
428432
idleExpiryMs: 40,
429433
executionLocks: new Map(),
@@ -485,7 +489,7 @@ test('a daemon beginning to leave does not start settling the next session', asy
485489
});
486490

487491
const controller = createSessionIdleExpiry({
488-
env: process.env,
492+
env: createTestHostEnvironment().env,
489493
sessionStore,
490494
idleExpiryMs: WINDOW_MS,
491495
executionLocks: new Map(),
@@ -526,7 +530,7 @@ test('an over-budget expiry keeps the locks the release itself needs', async ()
526530
});
527531

528532
const controller = createSessionIdleExpiry({
529-
env: process.env,
533+
env: createTestHostEnvironment().env,
530534
sessionStore,
531535
idleExpiryMs: WINDOW_MS,
532536
executionLocks: locks,
@@ -577,7 +581,7 @@ test('an expiry that lands after its budget still reports the session it release
577581
const expired: string[] = [];
578582

579583
const controller = createSessionIdleExpiry({
580-
env: process.env,
584+
env: createTestHostEnvironment().env,
581585
sessionStore,
582586
idleExpiryMs: WINDOW_MS,
583587
executionLocks: new Map(),
@@ -617,7 +621,7 @@ test('a stuck expiry does not leave the timer firing with no delay', async () =>
617621
let clock = NOW;
618622

619623
const controller = createSessionIdleExpiry({
620-
env: process.env,
624+
env: createTestHostEnvironment().env,
621625
sessionStore,
622626
idleExpiryMs: 20,
623627
executionLocks: new Map(),
@@ -678,7 +682,7 @@ test('a settle that outlives its window is retried a full window after it ends,
678682
let settledAt = 0;
679683

680684
const controller = createSessionIdleExpiry({
681-
env: process.env,
685+
env: createTestHostEnvironment().env,
682686
sessionStore,
683687
idleExpiryMs: WINDOW,
684688
executionLocks: new Map(),

‎packages/daemon/src/server/http/daemon-session-idle-expiry.test.ts‎

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
import { deviceClaimFilePath, bindTestCommandHost } from '@agent-device/test-kit';
1+
import {
2+
deviceClaimFilePath,
3+
bindTestCommandHost,
4+
createTestHostEnvironment,
5+
} from '@agent-device/test-kit';
26
import { test } from 'vitest';
37
import assert from 'node:assert/strict';
48
import fs from 'node:fs';
@@ -49,7 +53,7 @@ test('a session past its window releases its claim, is deleted, and leaves a mar
4953
assert.equal(claimFileHeld(deviceClaim), true, 'the fixture stands a claim that is really held');
5054
const sweeps = createSweepBarrier();
5155
const controller = createSessionIdleExpiry({
52-
env: process.env,
56+
env: createTestHostEnvironment().env,
5357
sessionStore,
5458
idleExpiryMs: WINDOW_MS,
5559
executionLocks: new Map(),
@@ -85,7 +89,7 @@ test('a settle that cannot confirm the claim gone keeps the session record stand
8589
try {
8690
const sweeps = createSweepBarrier();
8791
const controller = createSessionIdleExpiry({
88-
env: process.env,
92+
env: createTestHostEnvironment().env,
8993
sessionStore,
9094
idleExpiryMs: WINDOW_MS,
9195
executionLocks: new Map(),
@@ -125,7 +129,7 @@ test('a claim that yields no attributable owner keeps the session record standin
125129

126130
const sweeps = createSweepBarrier();
127131
const controller = createSessionIdleExpiry({
128-
env: process.env,
132+
env: createTestHostEnvironment().env,
129133
sessionStore,
130134
idleExpiryMs: WINDOW_MS,
131135
executionLocks: new Map(),
@@ -157,7 +161,7 @@ test('a settle that fails keeps the session and its claim, and retries on the ne
157161

158162
const sweeps = createSweepBarrier();
159163
const controller = createSessionIdleExpiry({
160-
env: process.env,
164+
env: createTestHostEnvironment().env,
161165
sessionStore,
162166
idleExpiryMs: WINDOW_MS,
163167
executionLocks: new Map(),
@@ -198,7 +202,7 @@ test('a session shutdown finalized mid-settle is not also reported as expired',
198202
const sweeps = createSweepBarrier();
199203

200204
const controller = createSessionIdleExpiry({
201-
env: process.env,
205+
env: createTestHostEnvironment().env,
202206
sessionStore,
203207
idleExpiryMs: WINDOW_MS,
204208
executionLocks: new Map(),
@@ -227,7 +231,7 @@ test('a session closed by its owner stops the retry clock tracking it', async ()
227231
let settleCalls = 0;
228232
const sweeps = createSweepBarrier();
229233
const controller = createSessionIdleExpiry({
230-
env: process.env,
234+
env: createTestHostEnvironment().env,
231235
sessionStore,
232236
idleExpiryMs: WINDOW_MS,
233237
executionLocks: new Map(),
@@ -270,7 +274,7 @@ test('a settled session of another kind is never touched by the sweep', async ()
270274

271275
const settledNames: string[] = [];
272276
const controller = createSessionIdleExpiry({
273-
env: process.env,
277+
env: createTestHostEnvironment().env,
274278
sessionStore,
275279
idleExpiryMs: WINDOW_MS,
276280
executionLocks: new Map(),
@@ -307,7 +311,7 @@ test('a held-back settle leaves a repair transaction uncommitted, so a later pas
307311
const claimsDir = path.dirname(deviceClaimFilePath(deviceClaim.deviceKey));
308312
const sweeps = createSweepBarrier();
309313
const settleParams = {
310-
env: process.env,
314+
env: createTestHostEnvironment().env,
311315
sessionStore,
312316
idleExpiryMs: WINDOW_MS,
313317
executionLocks: new Map(),
@@ -369,7 +373,7 @@ test('a committed expiry finalizes the repair transaction it ends', async () =>
369373

370374
const sweeps = createSweepBarrier();
371375
const controller = createSessionIdleExpiry({
372-
env: process.env,
376+
env: createTestHostEnvironment().env,
373377
sessionStore,
374378
idleExpiryMs: WINDOW_MS,
375379
executionLocks: new Map(),
@@ -404,7 +408,7 @@ test('an idle settle cannot finalize or retire a replacement at its scoped addre
404408
});
405409
let entered = false;
406410
const controller = createSessionIdleExpiry({
407-
env: process.env,
411+
env: createTestHostEnvironment().env,
408412
sessionStore,
409413
idleExpiryMs: WINDOW_MS,
410414
executionLocks: new Map(),

‎packages/daemon/src/sessions/handlers/__tests__/install-source.test.ts‎

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ import { AppError } from '@agent-device/kernel/errors';
2929
import {
3030
mkdtempForTestSync,
3131
unavailableApplicationLifecycleOperationFacts,
32-
createTestHostEnvironment,
3332
} from '@agent-device/test-kit';
3433
import type {
3534
BindDeviceRuntime,
@@ -92,7 +91,6 @@ test('install_source materializes and deploys through one admitted runtime bindi
9291
const runtime = createSourceRuntime(session.device, materialize, deploy);
9392

9493
const response = await handleInstallFromSourceDeploymentCommand({
95-
host: createTestHostEnvironment(),
9694
platformServices: daemonPlatformServicesFixture(),
9795
req: makeRequest({ kind: 'url', url: 'https://example.com/app.zip', headers: {} }),
9896
sessionName: session.name,
@@ -139,7 +137,6 @@ test('install_source rejects unavailable facts before binding or materializing',
139137
});
140138

141139
const response = await handleInstallFromSourceDeploymentCommand({
142-
host: createTestHostEnvironment(),
143140
platformServices: daemonPlatformServicesFixture(),
144141
req: makeRequest({ kind: 'url', url: 'https://example.com/app.zip' }),
145142
sessionName: session.name,
@@ -178,7 +175,6 @@ test('install_source fails closed when a provider owner does not expose readines
178175
});
179176

180177
const response = await handleInstallFromSourceDeploymentCommand({
181-
host: createTestHostEnvironment(),
182178
platformServices: daemonPlatformServicesFixture(),
183179
req: makeRequest({ kind: 'url', url: 'https://example.com/app.zip' }),
184180
sessionName: session.name,
@@ -236,7 +232,6 @@ test('install_source cleans materialized paths when deployment fails after admis
236232
);
237233

238234
const response = await handleInstallFromSourceDeploymentCommand({
239-
host: createTestHostEnvironment(),
240235
platformServices: daemonPlatformServicesFixture(),
241236
req: makeRequest({ kind: 'url', url: 'https://example.com/app.zip' }),
242237
sessionName: session.name,
@@ -269,7 +264,6 @@ test('install_source preserves the Android identity failure when its runtime can
269264
);
270265

271266
const response = await handleInstallFromSourceDeploymentCommand({
272-
host: createTestHostEnvironment(),
273267
platformServices: daemonPlatformServicesFixture(),
274268
req: makeRequest({ kind: 'url', url: 'https://example.com/app.zip' }),
275269
sessionName: session.name,
@@ -306,7 +300,6 @@ test('install_source returns the typed iOS artifact identity supplied by its run
306300
);
307301

308302
const response = await handleInstallFromSourceDeploymentCommand({
309-
host: createTestHostEnvironment(),
310303
platformServices: daemonPlatformServicesFixture(),
311304
req: makeRequest({ kind: 'path', path: '/tmp/AgentDeviceTester.app' }),
312305
sessionName: session.name,
@@ -354,7 +347,6 @@ test('install_source accepts the public leaf selector of an Apple session it is
354347
);
355348

356349
const response = await handleInstallFromSourceDeploymentCommand({
357-
host: createTestHostEnvironment(),
358350
platformServices: daemonPlatformServicesFixture(),
359351
req: makeRequest({ kind: 'path', path: '/tmp/App.app' }, { platform: 'ios' }),
360352
sessionName: session.name,
@@ -384,7 +376,6 @@ test('install_source still refuses a leaf selector that names a different platfo
384376
);
385377

386378
const response = await handleInstallFromSourceDeploymentCommand({
387-
host: createTestHostEnvironment(),
388379
platformServices: daemonPlatformServicesFixture(),
389380
req: makeRequest({ kind: 'path', path: '/tmp/App.app' }, { platform: 'android' }),
390381
sessionName: session.name,

‎packages/daemon/src/sessions/handlers/session-app-deployment-route.ts‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ export async function handleSessionAppDeploymentCommand(params: {
4040
}
4141
if (req.command === 'install_source') {
4242
return await handleInstallFromSourceDeploymentCommand({
43-
host,
4443
req,
4544
sessionName,
4645
sessionStore,

‎packages/daemon/src/sessions/handlers/session-app-source-deployment.ts‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import type { HostEnvironment } from '@agent-device/kernel/source-value';
21
import type { DaemonResponse } from '@agent-device/kernel/contracts';
32
import type { DaemonPlatformServices } from '../../core/platform-services.ts';
43
import type {
@@ -50,7 +49,6 @@ type InstallFromSourceResult = Readonly<{
5049
}>;
5150

5251
export async function handleInstallFromSourceDeploymentCommand(params: {
53-
host: HostEnvironment;
5452
req: DaemonRequest;
5553
sessionName: string;
5654
sessionStore: SessionStore;

‎packages/daemon/src/sessions/request-handler-chain.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ import type { PlatformResourceCleanup } from '../core/platform-resource-cleanup.
3131
import type { DaemonProviderCredentials } from '@agent-device/daemon-contracts/provider-credentials';
3232

3333
type RequestHandlerChainParams = {
34-
/** The environment and working directory this request's handlers read configuration from. */
34+
/** The environment and working directory the session and record-trace routes read configuration from. */
3535
host: HostEnvironment;
3636
req: DaemonRequest;
3737
sessionName: string;

0 commit comments

Comments
 (0)