Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
6b753bf
docs(onboard): document FSM migration target
cv May 27, 2026
fb1b32d
refactor(onboard): centralize machine state metadata
cv May 27, 2026
c3e4ad6
refactor(onboard): derive session step mapping from FSM metadata
cv May 27, 2026
603832c
refactor(onboard): derive progress labels from FSM metadata
cv May 27, 2026
4fad8e7
fix(onboard): emit lifecycle events for onboarding start
cv May 28, 2026
f99e9cb
fix(onboard): emit machine events for resume conflicts
cv May 28, 2026
2b60df4
refactor(onboard): introduce explicit state result types
cv May 28, 2026
30341b0
refactor(onboard): apply explicit state results through runtime
cv May 28, 2026
d4ad2d9
refactor(onboard): make finalization return FSM result
cv May 28, 2026
356c947
refactor(onboard): make agent setup return FSM result
cv May 28, 2026
2296519
refactor(onboard): make policy setup return FSM result
cv May 28, 2026
67a9a1e
refactor(onboard): make preflight and gateway return FSM results
cv May 28, 2026
46f4a49
refactor(onboard): make sandbox return branch FSM result
cv May 28, 2026
9cc15f5
refactor(onboard): return FSM results from provider inference
cv May 28, 2026
dbbb273
refactor(onboard): add FSM runner shell
cv May 28, 2026
6b27a0b
refactor(onboard): consume handler FSM results compatibly
cv May 28, 2026
44009ad
refactor(onboard): allow step recording without machine transitions
cv May 28, 2026
cd6e5f7
refactor(onboard): plumb step mutation options through runtime
cv May 28, 2026
e266e3b
refactor(onboard): add record-only FSM runner adapter
cv May 28, 2026
bf4da0b
refactor(onboard): return ordered provider FSM results
cv May 28, 2026
212ff4d
refactor(onboard): run live sequence with record-only steps
cv May 28, 2026
f69f60a
refactor(onboard): let FSM handlers return result sequences
cv May 29, 2026
727ac69
refactor(onboard): add sequence runner adapter
cv May 29, 2026
75f82f7
refactor(onboard): support FSM runner stop states
cv May 29, 2026
59deee6
refactor(onboard): define FSM flow context
cv May 29, 2026
25c5abf
refactor(onboard): extract preflight and gateway FSM phases
cv May 29, 2026
a1af752
merge(onboard): sync FSM stop states with main
cv Jun 9, 2026
5900708
merge(onboard): sync flow context with stop states
cv Jun 9, 2026
8576e5f
merge(onboard): sync preflight phases with flow context
cv Jun 9, 2026
5c7b7ee
Merge branch 'main' into stack/onboard-fsm-flow-context
jyaunches Jun 9, 2026
83c1412
Merge branch 'main' into stack/onboard-fsm-flow-context
cv Jun 9, 2026
6abbbb4
Merge branch 'stack/onboard-fsm-flow-context' into stack/onboard-fsm-…
cv Jun 9, 2026
23e8577
Merge branch 'main' into stack/onboard-fsm-flow-context
cv Jun 9, 2026
abbd8c4
chore: apply static formatting for FSM flow stack
cv Jun 9, 2026
b592eac
Merge remote-tracking branch 'origin/stack/onboard-fsm-flow-context' …
cv Jun 9, 2026
adbbdfa
chore(onboard): format preflight gateway FSM phase
cv Jun 9, 2026
c123223
Merge branch 'main' into stack/onboard-fsm-preflight-gateway-phases
cv Jun 9, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
76 changes: 76 additions & 0 deletions src/lib/onboard/machine/flow-phases/preflight-gateway.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
// SPDX-License-Identifier: Apache-2.0

import { describe, expect, it, vi } from "vitest";

import { createSession } from "../../../state/onboard-session";
import { advanceTo } from "../result";
import type { OnboardFlowContext } from "../flow-context";
import { createGatewayPhase, createPreflightPhase } from "./preflight-gateway";

function context(): OnboardFlowContext<null, { type: string }, { mode: string }> {
return {
resume: false,
fresh: false,
session: createSession(),
agent: null,
recordedSandboxName: null,
requestedSandboxName: null,
sandboxName: null,
fromDockerfile: null,
model: null,
provider: null,
endpointUrl: null,
credentialEnv: null,
hermesAuthMethod: null,
hermesToolGateways: [],
preferredInferenceApi: null,
nimContainer: null,
webSearchConfig: null,
webSearchSupported: false,
selectedMessagingChannels: [],
gpu: null,
sandboxGpuConfig: null,
gpuPassthrough: false,
};
}

describe("preflight/gateway flow phases", () => {
it("maps preflight handler outputs into flow context and FSM result", async () => {
const session = createSession({ gpuPassthrough: true });
const runPreflight = vi.fn(async () => ({
session,
gpu: { type: "nvidia" },
sandboxGpuConfig: { mode: "1" },
gpuPassthrough: true,
result: advanceTo("gateway"),
}));
const phase = createPreflightPhase(runPreflight);

const result = await phase.run(context());

expect(phase.state).toBe("preflight");
expect(runPreflight).toHaveBeenCalledOnce();
expect(result.context).toMatchObject({
session,
gpu: { type: "nvidia" },
sandboxGpuConfig: { mode: "1" },
gpuPassthrough: true,
});
expect(result.result).toMatchObject({ next: "gateway" });
});

it("maps gateway handler outputs into flow context and FSM result", async () => {
const session = createSession({ sandboxName: "my-assistant" });
const phase = createGatewayPhase(async () => ({
session,
result: advanceTo("provider_selection"),
}));

const result = await phase.run(context());

expect(phase.state).toBe("gateway");
expect(result.context.session).toBe(session);
expect(result.result).toMatchObject({ next: "provider_selection" });
});
});
54 changes: 54 additions & 0 deletions src/lib/onboard/machine/flow-phases/preflight-gateway.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
// SPDX-License-Identifier: Apache-2.0

import type { OnboardFlowContext, OnboardFlowPhaseResult } from "../flow-context";
import { mergeOnboardFlowContext, onboardFlowPhaseResult } from "../flow-context";
import type { OnboardSequencePhase } from "../sequence-runner";

type PreflightPhaseHandler<Context extends OnboardFlowContext> = (context: Context) => Promise<{
session: Context["session"];
gpu: Context["gpu"];
sandboxGpuConfig: NonNullable<Context["sandboxGpuConfig"]>;
gpuPassthrough: boolean;
result: OnboardFlowPhaseResult<Context>["result"];
}>;

type GatewayPhaseHandler<Context extends OnboardFlowContext> = (context: Context) => Promise<{
session: Context["session"];
result: OnboardFlowPhaseResult<Context>["result"];
}>;

export function createPreflightPhase<Context extends OnboardFlowContext>(
runPreflight: PreflightPhaseHandler<Context>,
): OnboardSequencePhase<Context> {
return {
state: "preflight",
async run(context) {
const result = await runPreflight(context);
return onboardFlowPhaseResult(
mergeOnboardFlowContext(context, {
session: result.session,
gpu: result.gpu,
sandboxGpuConfig: result.sandboxGpuConfig,
gpuPassthrough: result.gpuPassthrough,
} as Partial<Context>),
result.result,
);
},
};
}

export function createGatewayPhase<Context extends OnboardFlowContext>(
runGateway: GatewayPhaseHandler<Context>,
): OnboardSequencePhase<Context> {
return {
state: "gateway",
async run(context) {
const result = await runGateway(context);
return onboardFlowPhaseResult(
mergeOnboardFlowContext(context, { session: result.session } as Partial<Context>),
result.result,
);
},
};
}