Skip to content

Commit 5de949f

Browse files
committed
perf(cli): defer service imports from the update recovery entry
Keep the stable daemon entry cheap for installed update drivers by loading service, lifecycle, and handoff implementations only when invoked. Preserve the direct ledger exports and non-awaited terminal finalizer contract, and remove the superseded runners barrel. The original source-child pressure replay failed 12 of 44 cases during import before this change. The repaired entry passed 220 cases across 20 file repetitions with the unchanged 15-second deadline. Prepared child import time dropped from a 933 ms median to 391 ms on the same Testbox. Validated three original CLI shard replays, the complete CLI, CLI-process, and infra configurations, types, export scans, and a full build. Older drivers benefit when loading the new installed runtime; code already running from the previous installation remains unchanged.
1 parent d823120 commit 5de949f

2 files changed

Lines changed: 65 additions & 23 deletions

File tree

‎src/cli/daemon-cli.ts‎

Lines changed: 65 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,67 @@
1-
// Public daemon CLI barrel retained for gateway service command compatibility.
1+
// Stable entry for service commands and recovery calls from installed update drivers.
2+
import type {
3+
DaemonInstallOptions,
4+
DaemonLifecycleOptions,
5+
DaemonStatusOptions,
6+
} from "./daemon-cli/types.js";
7+
28
export { registerDaemonCli } from "./daemon-cli/register.js";
39
export { addGatewayServiceCommands } from "./daemon-cli/register-service-commands.js";
4-
export {
5-
runDaemonInstall,
6-
runDaemonRestart,
7-
runDaemonStart,
8-
runDaemonStatus,
9-
runDaemonStop,
10-
runDaemonUninstall,
11-
} from "./daemon-cli/runners.js";
1210
export type {
1311
DaemonInstallOptions,
1412
DaemonStatusOptions,
1513
GatewayRpcOpts,
1614
} from "./daemon-cli/types.js";
1715

18-
export {
19-
isManagedUpdateRequesterOwner,
20-
waitForGatewayUpdateRecovery,
21-
} from "./daemon-cli/lifecycle-context.js";
16+
// Finalization must not load the service/plugin graph before settling the ledger.
17+
export async function runDaemonInstall(opts: DaemonInstallOptions) {
18+
const runtime = await import("./daemon-cli/install.js");
19+
return runtime.runDaemonInstall(opts);
20+
}
21+
22+
export async function runDaemonRestart(opts: DaemonLifecycleOptions = {}) {
23+
const runtime = await import("./daemon-cli/lifecycle.js");
24+
return runtime.runDaemonRestart(opts);
25+
}
26+
27+
export async function runDaemonStart(opts: DaemonLifecycleOptions = {}) {
28+
const runtime = await import("./daemon-cli/lifecycle.js");
29+
return runtime.runDaemonStart(opts);
30+
}
31+
32+
export async function runDaemonStop(opts: DaemonLifecycleOptions = {}) {
33+
const runtime = await import("./daemon-cli/lifecycle.js");
34+
return runtime.runDaemonStop(opts);
35+
}
36+
37+
export async function runDaemonUninstall(opts: DaemonLifecycleOptions = {}) {
38+
const runtime = await import("./daemon-cli/lifecycle.js");
39+
return runtime.runDaemonUninstall(opts);
40+
}
41+
42+
export async function runDaemonStatus(opts: DaemonStatusOptions) {
43+
const runtime = await import("./daemon-cli/status.js");
44+
return runtime.runDaemonStatus(opts);
45+
}
46+
47+
export async function isManagedUpdateRequesterOwner(
48+
...args: Parameters<
49+
typeof import("./daemon-cli/lifecycle-context.js").isManagedUpdateRequesterOwner
50+
>
51+
) {
52+
const runtime = await import("./daemon-cli/lifecycle-context.js");
53+
return runtime.isManagedUpdateRequesterOwner(...args);
54+
}
55+
56+
export async function waitForGatewayUpdateRecovery(
57+
...args: Parameters<
58+
typeof import("./daemon-cli/lifecycle-context.js").waitForGatewayUpdateRecovery
59+
>
60+
) {
61+
const runtime = await import("./daemon-cli/lifecycle-context.js");
62+
return runtime.waitForGatewayUpdateRecovery(...args);
63+
}
64+
2265
// Handoff admission uses the serving runtime; terminal writes load the installed runtime afresh.
2366
export {
2467
adoptUpdateRun,
@@ -33,4 +76,12 @@ export {
3376
createManagedUpdateRequesterAuthority,
3477
prepareManagedUpdateRequesterIdentity,
3578
} from "../infra/update-requester-authority.js";
36-
export { assertForegroundUpdateOrigin } from "../infra/update-managed-service-handoff.js";
79+
80+
export async function assertForegroundUpdateOrigin(
81+
...args: Parameters<
82+
typeof import("../infra/update-managed-service-handoff.js").assertForegroundUpdateOrigin
83+
>
84+
) {
85+
const runtime = await import("../infra/update-managed-service-handoff.js");
86+
return runtime.assertForegroundUpdateOrigin(...args);
87+
}

‎src/cli/daemon-cli/runners.ts‎

Lines changed: 0 additions & 9 deletions
This file was deleted.

0 commit comments

Comments
 (0)