Skip to content

Commit ab42b04

Browse files
committed
refactor: cover install cutover in shared gate
1 parent 9e21120 commit ab42b04

6 files changed

Lines changed: 165 additions & 45 deletions

File tree

‎scripts/layering/runtime-command-cutover-table.ts‎

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,102 @@ export const MIGRATED_COMMAND_CUTOVERS: readonly MigratedCommandCutover[] = [
3636
operations: ['bootTarget', 'bootTargetHeadless'],
3737
},
3838
},
39+
{
40+
rule: 'R19 install-runtime-cutover',
41+
command: 'install',
42+
subject: 'app installation',
43+
tier: 'request-scoped',
44+
execution: 'device-runtime',
45+
legacyRetirement: {
46+
modulePaths: ['src/daemon/handlers/session-deploy.ts'],
47+
importPatterns: [/(?:^|\/)session-deploy(?:\.[cm]?[jt]s)?$/],
48+
routeNames: [
49+
'APP_INSTALL_CAPABILITY',
50+
'defaultInstallOps',
51+
'handleAppDeployCommand',
52+
'installProviderDeviceApp',
53+
],
54+
},
55+
admissionMember: {
56+
forms: ['computed-property'],
57+
files: ['src/platforms/apple/plugin.ts'],
58+
message: 'Apple plugin retains legacy install support or hint closure',
59+
},
60+
runtimeTypeNames: ['AppDeploymentRuntimeOperations'],
61+
operations: { names: ['deployApp'] },
62+
singularExecution: {
63+
routes: ['handleAppDeploymentCommand'],
64+
operations: ['deployApp'],
65+
},
66+
},
67+
{
68+
rule: 'R20 reinstall-runtime-cutover',
69+
command: 'reinstall',
70+
subject: 'app reinstallation',
71+
tier: 'request-scoped',
72+
execution: 'device-runtime',
73+
legacyRetirement: {
74+
modulePaths: ['src/daemon/handlers/session-deploy.ts'],
75+
importPatterns: [/(?:^|\/)session-deploy(?:\.[cm]?[jt]s)?$/],
76+
routeNames: [
77+
'APP_INSTALL_CAPABILITY',
78+
'defaultReinstallOps',
79+
'handleAppDeployCommand',
80+
'installProviderDeviceApp',
81+
],
82+
},
83+
admissionMember: {
84+
forms: ['computed-property'],
85+
files: ['src/platforms/apple/plugin.ts'],
86+
message: 'Apple plugin retains legacy reinstall support or hint closure',
87+
},
88+
runtimeTypeNames: ['AppDeploymentRuntimeOperations'],
89+
operations: { names: ['deployApp'] },
90+
singularExecution: {
91+
routes: ['handleAppDeploymentCommand'],
92+
operations: ['deployApp'],
93+
},
94+
},
95+
{
96+
rule: 'R21 install-source-runtime-cutover',
97+
command: 'install_source',
98+
subject: 'source installation',
99+
tier: 'request-scoped',
100+
execution: 'device-runtime',
101+
legacyRetirement: {
102+
modulePaths: ['src/daemon/handlers/install-source.ts'],
103+
routeNames: ['handleInstallFromSourceCommand', 'installProviderDeviceInstallablePath'],
104+
},
105+
runtimeTypeNames: ['AppDeploymentRuntimeOperations', 'DeviceReadinessRuntimeOperations'],
106+
operations: {
107+
names: ['ensureReady', 'materializeAppSource', 'deployMaterializedApp'],
108+
},
109+
singularExecution: {
110+
routes: ['handleInstallFromSourceDeploymentCommand'],
111+
operations: ['ensureReady', 'materializeAppSource', 'deployMaterializedApp'],
112+
},
113+
},
114+
{
115+
rule: 'R22 push-runtime-cutover',
116+
command: 'push',
117+
subject: 'push notification',
118+
tier: 'request-scoped',
119+
execution: 'device-runtime',
120+
legacyRetirement: {
121+
routeNames: ['handlePushCommand'],
122+
},
123+
admissionMember: {
124+
forms: ['computed-property'],
125+
files: ['src/platforms/apple/plugin.ts'],
126+
message: 'Apple plugin retains legacy push support or hint closure',
127+
},
128+
runtimeTypeNames: ['AppDeploymentRuntimeOperations', 'DeviceReadinessRuntimeOperations'],
129+
operations: { names: ['ensureReady', 'sendPushNotification'] },
130+
singularExecution: {
131+
routes: ['handlePushNotificationCommand'],
132+
operations: ['ensureReady', 'sendPushNotification'],
133+
},
134+
},
39135
{
40136
rule: 'R17 device-inventory-cutover',
41137
command: 'devices',
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
import type { BindDeviceRuntime, InspectDeviceRuntimeFacts } from '../request-runtime-binding.ts';
2+
import { SessionStore } from '../session-store.ts';
3+
import type { DaemonRequest, DaemonResponse } from '../types.ts';
4+
import {
5+
handleAppDeploymentCommand,
6+
handlePushNotificationCommand,
7+
} from './session-app-deployment.ts';
8+
import { handleInstallFromSourceDeploymentCommand } from './session-app-source-deployment.ts';
9+
10+
/** The four canonical install-family descriptors share one daemon route boundary. */
11+
export async function handleSessionAppDeploymentCommand(params: {
12+
req: DaemonRequest;
13+
sessionName: string;
14+
sessionStore: SessionStore;
15+
inspectFacts?: InspectDeviceRuntimeFacts;
16+
bindDevice?: BindDeviceRuntime;
17+
}): Promise<DaemonResponse | null> {
18+
const { req, sessionName, sessionStore, inspectFacts, bindDevice } = params;
19+
if (req.command === 'install' || req.command === 'reinstall') {
20+
return await handleAppDeploymentCommand({
21+
req,
22+
command: req.command,
23+
sessionName,
24+
sessionStore,
25+
inspectFacts,
26+
bindDevice,
27+
});
28+
}
29+
if (req.command === 'install_source') {
30+
return await handleInstallFromSourceDeploymentCommand({
31+
req,
32+
sessionName,
33+
sessionStore,
34+
inspectFacts,
35+
bindDevice,
36+
});
37+
}
38+
if (req.command === 'push') {
39+
return await handlePushNotificationCommand({
40+
req,
41+
sessionName,
42+
sessionStore,
43+
inspectFacts,
44+
bindDevice,
45+
});
46+
}
47+
return null;
48+
}

‎src/daemon/handlers/session-app-deployment.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import { recordSessionAction } from './handler-utils.ts';
1818
import { errorResponse } from './response.ts';
1919
import { requireSessionOrExplicitSelector, resolveCommandDevice } from './session-device-utils.ts';
2020
import {
21+
ensureRuntimeReady,
2122
requireRuntimeBinding,
2223
requireRuntimeFacts,
2324
unavailableRuntimeOperationResponse,
@@ -125,7 +126,7 @@ export async function handlePushNotificationCommand(params: {
125126
device,
126127
readySendPushNotificationUse,
127128
);
128-
await runtime.operations.ensureReady({});
129+
await ensureRuntimeReady(runtime);
129130
const result = await runtime.operations.sendPushNotification({ appId, payload });
130131
const data = isIosFamily(device)
131132
? withSuccessText({ platform: 'ios', bundleId: appId }, `Pushed notification to ${appId}`)

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import { withSuccessText } from '../../utils/success-text.ts';
1717
import { recordSessionAction } from './handler-utils.ts';
1818
import { resolveCommandDevice } from './session-device-utils.ts';
1919
import {
20+
ensureRuntimeReady,
2021
requireRuntimeBinding,
2122
requireRuntimeFacts,
2223
unavailableRuntimeOperationResponse,
@@ -67,7 +68,7 @@ export async function handleInstallFromSourceDeploymentCommand(params: {
6768
device,
6869
readyMaterializeAndDeployAppUse,
6970
);
70-
await runtime.operations.ensureReady({});
71+
await ensureRuntimeReady(runtime);
7172
materialized = await runtime.operations.materializeAppSource({ source: resolvedSource.source });
7273
retained = await retainIfRequested({
7374
artifact: materialized,

‎src/daemon/handlers/session-runtime-admission.ts‎

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
import type { RuntimeOperationFact } from '@agent-device/contracts/platform';
1+
import type {
2+
PlatformRuntimeOperations,
3+
RuntimeOperationFact,
4+
} from '@agent-device/contracts/platform';
25
import { AppError } from '@agent-device/kernel/errors';
36
import type { BindDeviceRuntime, InspectDeviceRuntimeFacts } from '../request-runtime-binding.ts';
47
import type { DaemonResponse } from '../types.ts';
@@ -31,3 +34,10 @@ export function requireRuntimeBinding(
3134
if (bindDevice) return bindDevice;
3235
throw new AppError('COMMAND_FAILED', 'Device runtime binding is unavailable.');
3336
}
37+
38+
/** Executes the bound owner's readiness operation; it never supplies a daemon fallback. */
39+
export async function ensureRuntimeReady(
40+
runtime: Readonly<{ operations: Pick<PlatformRuntimeOperations, 'ensureReady'> }>,
41+
): Promise<void> {
42+
await runtime.operations.ensureReady({});
43+
}

‎src/daemon/handlers/session.ts‎

Lines changed: 6 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,8 @@ import {
2222
resolveSessionAppBundleIdForTarget,
2323
} from './session-open-target.ts';
2424
import { handleCloseCommand } from './session-close.ts';
25-
import {
26-
handleAppDeploymentCommand,
27-
handlePushNotificationCommand,
28-
} from './session-app-deployment.ts';
29-
import {
30-
handleInstallFromSourceDeploymentCommand,
31-
handleReleaseMaterializedPathsCommand,
32-
} from './session-app-source-deployment.ts';
25+
import { handleReleaseMaterializedPathsCommand } from './session-app-source-deployment.ts';
26+
import { handleSessionAppDeploymentCommand } from './session-app-deployment-route.ts';
3327
import { runBatchCommands } from './session-batch.ts';
3428
import { handleSessionInventoryCommands } from './session-inventory.ts';
3529
import { handleSessionStateCommands } from './session-state.ts';
@@ -458,42 +452,12 @@ const SESSION_COMMAND_HANDLER_IMPLS = {
458452
audio: handleSessionObservabilityCommandGroup,
459453
prepare: async ({ req, sessionName, logPath, sessionStore }) =>
460454
await handlePrepareCommand({ req, sessionName, logPath, sessionStore }),
461-
install: async ({ req, sessionName, sessionStore, inspectFacts, bindDevice }) =>
462-
await handleAppDeploymentCommand({
463-
req,
464-
command: 'install',
465-
sessionName,
466-
sessionStore,
467-
inspectFacts,
468-
bindDevice,
469-
}),
470-
reinstall: async ({ req, sessionName, sessionStore, inspectFacts, bindDevice }) =>
471-
await handleAppDeploymentCommand({
472-
req,
473-
command: 'reinstall',
474-
sessionName,
475-
sessionStore,
476-
inspectFacts,
477-
bindDevice,
478-
}),
479-
install_source: async ({ req, sessionName, sessionStore, inspectFacts, bindDevice }) =>
480-
await handleInstallFromSourceDeploymentCommand({
481-
req,
482-
sessionName,
483-
sessionStore,
484-
inspectFacts,
485-
bindDevice,
486-
}),
455+
install: handleSessionAppDeploymentCommand,
456+
reinstall: handleSessionAppDeploymentCommand,
457+
install_source: handleSessionAppDeploymentCommand,
487458
release_materialized_paths: async ({ req }) =>
488459
await handleReleaseMaterializedPathsCommand({ req }),
489-
push: async ({ req, sessionName, sessionStore, inspectFacts, bindDevice }) =>
490-
await handlePushNotificationCommand({
491-
req,
492-
sessionName,
493-
sessionStore,
494-
inspectFacts,
495-
bindDevice,
496-
}),
460+
push: handleSessionAppDeploymentCommand,
497461
'trigger-app-event': handleTriggerAppEventCommand,
498462
open: async ({ req, sessionName, logPath, sessionStore, reconcileOrphanedDeviceClaim }) =>
499463
await composeOpenWithInitialSnapshot({

0 commit comments

Comments
 (0)