| 1 | import { assert } from "@effect/vitest"; |
| 2 | import type { ProviderReplayTranscript } from "@t3tools/contracts"; |
| 3 | |
| 4 | import type { OrchestratorV2ScenarioResult } from "../../OrchestratorScenario.ts"; |
| 5 | import { |
| 6 | assertAssistantTextIncludes, |
| 7 | assertBaseProjection, |
| 8 | assertRuntimeRequestCounts, |
| 9 | assertSemanticProjectionIntegrity, |
| 10 | assertTurnItemTypes, |
| 11 | assertUserMessageInputIntents, |
| 12 | assertUserMessagesInclude, |
| 13 | MESSAGE_STEERING_INITIAL_PROMPT, |
| 14 | MESSAGE_STEERING_STEER_PROMPT, |
| 15 | projectionFor, |
| 16 | } from "../shared.ts"; |
| 17 | |
| 18 | export function assertGrokMessageSteeringOutput( |
| 19 | result: OrchestratorV2ScenarioResult, |
| 20 | transcript: ProviderReplayTranscript, |
| 21 | ) { |
| 22 | assertBaseProjection({ result, transcript, runCount: 1, runStatuses: ["completed"] }); |
| 23 | |
| 24 | const projection = projectionFor(result, transcript.scenario); |
| 25 | assertSemanticProjectionIntegrity(projection); |
| 26 | assertTurnItemTypes(projection, ["user_message", "assistant_message"]); |
| 27 | assertRuntimeRequestCounts(projection, { total: 0 }); |
| 28 | assertUserMessagesInclude(projection, [ |
| 29 | MESSAGE_STEERING_INITIAL_PROMPT, |
| 30 | MESSAGE_STEERING_STEER_PROMPT, |
| 31 | ]); |
| 32 | assertUserMessageInputIntents(projection, ["turn_start", "steer"]); |
| 33 | assertAssistantTextIncludes(projection, "steering fixture observed"); |
| 34 | |
| 35 | assert.lengthOf(projection.runs, 1, "steering must preserve the app run"); |
| 36 | assert.deepEqual( |
| 37 | projection.attempts.map((attempt) => [attempt.reason, attempt.status]), |
| 38 | [ |
| 39 | ["initial", "superseded"], |
| 40 | ["steering_restart", "completed"], |
| 41 | ], |
| 42 | ); |
| 43 | assert.deepEqual( |
| 44 | projection.providerTurns.map((turn) => turn.status), |
| 45 | ["interrupted", "completed"], |
| 46 | ); |
| 47 | assert.equal(projection.runs[0]?.activeAttemptId, projection.attempts[1]?.id); |
| 48 | assert.equal(projection.runs[0]?.rootNodeId, projection.attempts[1]?.rootNodeId); |
| 49 | assert.isFalse( |
| 50 | projection.turnItems.some( |
| 51 | (item) => item.type === "run_interrupt_request" || item.type === "run_interrupt_result", |
| 52 | ), |
| 53 | "steer supersede must not project run_interrupt_* items (those are hard Stop only)", |
| 54 | ); |
| 55 | } |