Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { describe, expect, it } from "vitest";

import type { OnboardFlowContext } from "../flow-context";
import { advanceTo, completeOnboardMachine } from "../result";
import { OnboardRuntime, type OnboardRuntimeDeps } from "../runtime";
import { runOnboardSequenceWithRunner } from "../sequence-runner";
import {
createAgentSetupPhase,
Expand All @@ -17,8 +16,6 @@ import {
import {
MACHINE_SNAPSHOT_VERSION,
type Session,
type SessionUpdates,
cloneSession,
createSession,
createTestRuntime,
} from "../../../../../test/helpers/onboard-machine-runtime-fixture";
Expand Down
3 changes: 0 additions & 3 deletions src/lib/onboard/machine/flow-sequence.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,10 @@ import type { OnboardFlowContext, OnboardFlowPhaseResult } from "./flow-context"
import { onboardFlowPhaseResult } from "./flow-context";
import { buildOnboardFlowPhaseSequence } from "./flow-sequence";
import { advanceTo, branchTo, completeOnboardMachine } from "./result";
import { OnboardRuntime, type OnboardRuntimeDeps } from "./runtime";
import { runOnboardSequenceWithRunner } from "./sequence-runner";
import {
MACHINE_SNAPSHOT_VERSION,
type Session,
type SessionUpdates,
cloneSession,
createSession,
createTestRuntime,
} from "../../../../test/helpers/onboard-machine-runtime-fixture";
Expand Down
4 changes: 0 additions & 4 deletions src/lib/onboard/machine/runner-sequence.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,8 @@ import {
type OnboardStateHandlers,
runOnboardMachine,
} from "./runner";
import { OnboardRuntime, type OnboardRuntimeDeps } from "./runtime";
import {
MACHINE_SNAPSHOT_VERSION,
type Session,
type SessionUpdates,
cloneSession,
createSession,
createTestRuntime as createRuntime,
} from "../../../../test/helpers/onboard-machine-runtime-fixture";
Expand Down
4 changes: 0 additions & 4 deletions src/lib/onboard/machine/runner.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,8 @@ import {
type OnboardStateHandlers,
runOnboardMachine,
} from "./runner";
import { OnboardRuntime, type OnboardRuntimeDeps } from "./runtime";
import {
MACHINE_SNAPSHOT_VERSION,
type Session,
type SessionUpdates,
cloneSession,
createSession,
createTestRuntime as createRuntime,
} from "../../../../test/helpers/onboard-machine-runtime-fixture";
Expand Down
13 changes: 13 additions & 0 deletions src/lib/onboard/machine/runtime.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,19 @@ function sessionInState(state: Session["machine"]["state"]): Session {
return session;
}

describe("onboard machine runtime fixture", () => {
it("keeps fallback clones isolated when normalization rejects a session (#8289)", () => {
const original = createSession();
original.version = 0;

const cloned = cloneSession(original);
cloned.steps.preflight.status = "complete";

expect(cloned).not.toBe(original);
expect(original.steps.preflight.status).toBe("pending");
});
});

describe("OnboardRuntime", () => {
it("starts a session and emits started/resumed lifecycle events", async () => {
const { runtime, events, getSession } = createHarness(null);
Expand Down
3 changes: 0 additions & 3 deletions src/lib/onboard/machine/sequence-runner.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import { describe, expect, it } from "vitest";

import { advanceTo, branchTo, completeOnboardMachine, retryTo } from "./result";
import { OnboardRuntime, type OnboardRuntimeDeps } from "./runtime";
import {
buildOnboardSequenceHandlers,
DuplicateOnboardSequencePhaseError,
Expand All @@ -13,8 +12,6 @@ import {
} from "./sequence-runner";
import {
type Session,
type SessionUpdates,
cloneSession,
createSession,
createTestRuntime,
} from "../../../../test/helpers/onboard-machine-runtime-fixture";
Expand Down
3 changes: 2 additions & 1 deletion test/helpers/onboard-machine-runtime-fixture.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ export type { Session, SessionUpdates } from "../../src/lib/state/onboard-sessio

/** A deep session copy that survives independent mutation. */
export function cloneSession(session: Session): Session {
return normalizeSession(JSON.parse(JSON.stringify(session))) ?? session;
const copy = JSON.parse(JSON.stringify(session)) as Session;
return normalizeSession(copy) ?? copy;
}

/** Behavior options for createTestRuntime. */
Expand Down
Loading