Repository navigation
refactor(onboard): extract flow handoff context #7717
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
cv
merged 23 commits into
codex/onboard-fsm-runtime-authority
from
codex/onboard-fsm-thin-entrypoint
Aug 3, 2026
Merged
Changes from 1 commit
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
7db13c1
refactor(onboard): extract flow handoff context
cv ea6d595
test(onboard): cover sandbox name precedence
cv 5477a39
merge(onboard): refresh FSM stack base
cv 7d63d3c
test(onboard): cover final handoff guards
cv 94d1ca3
merge(onboard): refresh FSM stack base
cv 7d51871
merge(onboard): refresh FSM stack base
cv 853e7bf
refactor(onboard): route handoffs through core flow
cv 01aa8c3
merge(onboard): refresh FSM stack base
cv 413b244
Merge remote-tracking branch 'origin/codex/onboard-fsm-runtime-author…
cv 5de3844
fix(onboard): align handoff tests with reasoning state
cv 30bcbbf
fix(onboard): remove unused handoff locals
cv f244b1d
test(onboard): align failed-session transition assertion
cv 54d121e
merge(stack): refresh #7717 from #7716
cv a644818
merge(onboard): refresh #7717 stack base
cv 036f0d4
test(onboard): assert failed session transition
cv 8e22f68
test(onboard): cover interrupted flow handoffs
cv 4c2bd95
test(onboard): use valid handoff endpoint fixtures
cv 4721b38
test(onboard): format handoff regression tests
cv 6c3c9cd
merge(onboard): refresh #7717 on current stack base
cv 6fba00e
merge: refresh PR #7717 from its base branch
cv 2562393
merge: refresh PR #7717 from its base branch
cv bf3b4c6
merge: refresh #7717 onto its base
cv 74d0248
merge: refresh #7717 onto #7716
cv File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,106 @@ | ||
| // 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 type { OnboardFlowContext } from "./flow-context"; | ||
| import { prepareCoreOnboardFlowContext, prepareFinalOnboardFlowContext } from "./flow-handoff"; | ||
|
|
||
| function context(): OnboardFlowContext & { | ||
| gpu: string | null; | ||
| sandboxGpuConfig: { mode: string } | null; | ||
| gpuPassthrough: boolean; | ||
| } { | ||
| return { | ||
| resume: false, | ||
| fresh: true, | ||
| 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, | ||
| compatibleEndpointReasoning: null, | ||
| nimContainer: null, | ||
| webSearchConfig: null, | ||
| webSearchSupported: false, | ||
| selectedMessagingChannels: [], | ||
| gpu: "nvidia", | ||
| sandboxGpuConfig: { mode: "cdi" }, | ||
| gpuPassthrough: true, | ||
| }; | ||
| } | ||
|
|
||
| describe("onboard flow handoffs", () => { | ||
| it("constructs core context from the initial result and requested name", () => { | ||
| const initialContext = context(); | ||
| const persisted = createSession(); | ||
| const assertSandboxNameAllowed = vi.fn(); | ||
|
|
||
| const result = prepareCoreOnboardFlowContext({ | ||
| initial: { context: initialContext, session: persisted }, | ||
| recordedSandboxName: null, | ||
| requestedSandboxName: "requested", | ||
| checkpointedSandboxName: "checkpointed", | ||
| selectedMessagingChannels: ["slack"], | ||
| assertSandboxNameAllowed, | ||
| }); | ||
|
|
||
| expect(result).toMatchObject({ | ||
| session: persisted, | ||
| sandboxName: "requested", | ||
| selectedMessagingChannels: ["slack"], | ||
| gpu: "nvidia", | ||
| sandboxGpuConfig: { mode: "cdi" }, | ||
| gpuPassthrough: true, | ||
| }); | ||
| expect(assertSandboxNameAllowed).toHaveBeenCalledWith("requested"); | ||
| }); | ||
|
|
||
| it("rejects a missing preflight GPU configuration", () => { | ||
| const initialContext = { ...context(), sandboxGpuConfig: null }; | ||
| const persisted = createSession(); | ||
|
|
||
| expect(() => | ||
| prepareCoreOnboardFlowContext({ | ||
| initial: { context: initialContext, session: persisted }, | ||
| recordedSandboxName: null, | ||
| requestedSandboxName: null, | ||
| checkpointedSandboxName: null, | ||
| selectedMessagingChannels: [], | ||
| assertSandboxNameAllowed: vi.fn(), | ||
| }), | ||
| ).toThrow("Preflight did not produce a sandbox GPU configuration."); | ||
| }); | ||
|
|
||
| it("constructs final context only after sandbox identity and inference are complete", () => { | ||
| const persisted = createSession(); | ||
| const coreContext = { | ||
| ...context(), | ||
| sandboxName: "ready", | ||
| model: "model", | ||
| provider: "provider", | ||
| }; | ||
|
|
||
| expect( | ||
| prepareFinalOnboardFlowContext({ | ||
| context: coreContext, | ||
| session: persisted, | ||
| }), | ||
| ).toMatchObject({ sandboxName: "ready", model: "model", provider: "provider" }); | ||
| expect(() => | ||
| prepareFinalOnboardFlowContext({ | ||
| context: { ...coreContext, model: null }, | ||
| session: persisted, | ||
| }), | ||
| ).toThrow("Onboarding state is incomplete after sandbox setup."); | ||
| }); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| // SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| import type { OnboardFlowContext } from "./flow-context"; | ||
| import type { OnboardMachineRunnerResult } from "./runner"; | ||
|
|
||
| type InitialHandoffContext<Gpu, SandboxGpuConfig> = OnboardFlowContext & { | ||
| readonly gpu: Gpu | null; | ||
| readonly sandboxGpuConfig: SandboxGpuConfig | null; | ||
| readonly gpuPassthrough: boolean; | ||
| }; | ||
|
|
||
| export function prepareCoreOnboardFlowContext< | ||
| Context extends InitialHandoffContext<Gpu, SandboxGpuConfig>, | ||
| Gpu, | ||
| SandboxGpuConfig, | ||
| >(options: { | ||
| initial: OnboardMachineRunnerResult<Context>; | ||
| recordedSandboxName: string | null; | ||
| requestedSandboxName: string | null; | ||
| checkpointedSandboxName: string | null; | ||
| selectedMessagingChannels: string[]; | ||
| assertSandboxNameAllowed(sandboxName: string): void; | ||
| }): Context & { sandboxGpuConfig: SandboxGpuConfig } { | ||
| const context = options.initial.context; | ||
| if (!context.sandboxGpuConfig) { | ||
| throw new Error("Preflight did not produce a sandbox GPU configuration."); | ||
| } | ||
| const sandboxName = | ||
| options.recordedSandboxName || | ||
| options.requestedSandboxName || | ||
| options.checkpointedSandboxName || | ||
| null; | ||
| if (sandboxName) options.assertSandboxNameAllowed(sandboxName); | ||
| return { | ||
| ...context, | ||
| session: options.initial.session, | ||
| sandboxName, | ||
| selectedMessagingChannels: options.selectedMessagingChannels, | ||
| gpu: context.gpu ?? null, | ||
| sandboxGpuConfig: context.sandboxGpuConfig, | ||
| gpuPassthrough: context.gpuPassthrough, | ||
| }; | ||
| } | ||
|
|
||
| export function prepareFinalOnboardFlowContext<Context extends OnboardFlowContext>( | ||
| core: OnboardMachineRunnerResult<Context>, | ||
| ): Context & { sandboxName: string; model: string; provider: string } { | ||
| const context = core.context; | ||
| if (!context.sandboxName || !context.model || !context.provider) { | ||
| throw new Error("Onboarding state is incomplete after sandbox setup."); | ||
| } | ||
| return { | ||
| ...context, | ||
| session: core.session, | ||
| sandboxName: context.sandboxName, | ||
| model: context.model, | ||
| provider: context.provider, | ||
| }; | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.