|
3 | 3 |
|
4 | 4 | import { afterEach, describe, expect, it, vi } from "vitest"; |
5 | 5 |
|
| 6 | +import { |
| 7 | + hostLocalInferenceReceipt, |
| 8 | + serializedHostLocalInferenceReceipt, |
| 9 | + serializedLlamaCppHostLocalInferenceReceipt, |
| 10 | +} from "../../../../test/helpers/host-local-inference-receipt"; |
6 | 11 | import type { |
7 | 12 | ProviderRecoveryReceipt, |
8 | 13 | RegistryInferenceRoute, |
9 | 14 | } from "../../onboard/rebuild-route-handoff"; |
| 15 | +import { serializeHostLocalInferenceReceipt } from "../../onboard/runtime-provider/host-local-inference"; |
10 | 16 | import type { SandboxBaseImageResolutionMetadata } from "../../sandbox-base-image"; |
11 | 17 | import { |
12 | 18 | pinRebuildTargetGatewayForReadiness, |
13 | 19 | runRebuildGatewayRecoveryAfterReadiness, |
14 | 20 | stageRebuildBaseImageResolutionHandoff, |
| 21 | + stageRecordedManagedVllmIntent, |
15 | 22 | stageRegistryProviderRecoveryReceipt, |
16 | 23 | } from "./rebuild-preflight-target-phase"; |
17 | 24 |
|
@@ -121,6 +128,152 @@ describe("stageRegistryProviderRecoveryReceipt", () => { |
121 | 128 | }); |
122 | 129 | }); |
123 | 130 |
|
| 131 | +describe("stageRecordedManagedVllmIntent", () => { |
| 132 | + const n1xExpressEntry = { |
| 133 | + provider: "vllm-local", |
| 134 | + model: "nvidia/Qwen3.6-35B-A3B-NVFP4", |
| 135 | + endpointUrl: null, |
| 136 | + endpointSource: "onboard" as const, |
| 137 | + openshellDriver: "docker", |
| 138 | + }; |
| 139 | + const n1xExpressSelection = { |
| 140 | + provider: n1xExpressEntry.provider, |
| 141 | + model: n1xExpressEntry.model, |
| 142 | + pinEndpoint: true, |
| 143 | + endpointUrl: null, |
| 144 | + }; |
| 145 | + |
| 146 | + it.each([ |
| 147 | + { state: "derived endpoint and absent receipt", sandboxEntry: n1xExpressEntry }, |
| 148 | + { |
| 149 | + state: "derived endpoint and null receipt", |
| 150 | + sandboxEntry: { ...n1xExpressEntry, hostLocalInferenceReceipt: null }, |
| 151 | + }, |
| 152 | + { |
| 153 | + state: "recorded canonical endpoint", |
| 154 | + sandboxEntry: { |
| 155 | + ...n1xExpressEntry, |
| 156 | + endpointUrl: "http://host.openshell.internal:8000/v1", |
| 157 | + }, |
| 158 | + }, |
| 159 | + ])( |
| 160 | + "carries the v0.0.109 N1x Express selection with a $state into rebuild readiness (#9292)", |
| 161 | + ({ sandboxEntry }) => { |
| 162 | + const recreateOptions: { allowDeferredN1xManagedVllm?: true } = {}; |
| 163 | + |
| 164 | + stageRecordedManagedVllmIntent(recreateOptions, sandboxEntry, n1xExpressSelection); |
| 165 | + |
| 166 | + expect(recreateOptions.allowDeferredN1xManagedVllm).toBe(true); |
| 167 | + }, |
| 168 | + ); |
| 169 | + |
| 170 | + it("also accepts a canonical vLLM receipt on the exact N1x Express selection (#9292)", () => { |
| 171 | + const recreateOptions: { allowDeferredN1xManagedVllm?: true } = {}; |
| 172 | + const genericReceipt = hostLocalInferenceReceipt("docker"); |
| 173 | + const n1xReceipt = serializeHostLocalInferenceReceipt({ |
| 174 | + ...genericReceipt, |
| 175 | + endpoint: { |
| 176 | + ...genericReceipt.endpoint, |
| 177 | + host: "host.openshell.internal", |
| 178 | + }, |
| 179 | + inference: { |
| 180 | + protocol: "openai-chat-completions", |
| 181 | + model: n1xExpressEntry.model, |
| 182 | + toolCallingRequired: true, |
| 183 | + }, |
| 184 | + }); |
| 185 | + |
| 186 | + stageRecordedManagedVllmIntent( |
| 187 | + recreateOptions, |
| 188 | + { ...n1xExpressEntry, hostLocalInferenceReceipt: n1xReceipt }, |
| 189 | + n1xExpressSelection, |
| 190 | + ); |
| 191 | + |
| 192 | + expect(recreateOptions.allowDeferredN1xManagedVllm).toBe(true); |
| 193 | + }); |
| 194 | + |
| 195 | + it.each([ |
| 196 | + { |
| 197 | + caseName: "different recorded provider", |
| 198 | + sandboxEntry: { ...n1xExpressEntry, provider: "compatible-endpoint" }, |
| 199 | + rebuildSelection: n1xExpressSelection, |
| 200 | + }, |
| 201 | + { |
| 202 | + caseName: "different recorded model", |
| 203 | + sandboxEntry: { ...n1xExpressEntry, model: "meta-llama/Llama-3.1-8B-Instruct" }, |
| 204 | + rebuildSelection: n1xExpressSelection, |
| 205 | + }, |
| 206 | + { |
| 207 | + caseName: "different recorded endpoint", |
| 208 | + sandboxEntry: { ...n1xExpressEntry, endpointUrl: "http://host.openshell.internal:8001/v1" }, |
| 209 | + rebuildSelection: n1xExpressSelection, |
| 210 | + }, |
| 211 | + { |
| 212 | + caseName: "different endpoint source", |
| 213 | + sandboxEntry: { ...n1xExpressEntry, endpointSource: "inference-set" as const }, |
| 214 | + rebuildSelection: n1xExpressSelection, |
| 215 | + }, |
| 216 | + { |
| 217 | + caseName: "different OpenShell driver", |
| 218 | + sandboxEntry: { ...n1xExpressEntry, openshellDriver: "podman" }, |
| 219 | + rebuildSelection: n1xExpressSelection, |
| 220 | + }, |
| 221 | + { |
| 222 | + caseName: "malformed receipt", |
| 223 | + sandboxEntry: { ...n1xExpressEntry, hostLocalInferenceReceipt: "not-json" }, |
| 224 | + rebuildSelection: n1xExpressSelection, |
| 225 | + }, |
| 226 | + { |
| 227 | + caseName: "different host-local service", |
| 228 | + sandboxEntry: { |
| 229 | + ...n1xExpressEntry, |
| 230 | + hostLocalInferenceReceipt: serializedLlamaCppHostLocalInferenceReceipt(), |
| 231 | + }, |
| 232 | + rebuildSelection: n1xExpressSelection, |
| 233 | + }, |
| 234 | + { |
| 235 | + caseName: "conflicting vLLM receipt", |
| 236 | + sandboxEntry: { |
| 237 | + ...n1xExpressEntry, |
| 238 | + hostLocalInferenceReceipt: serializedHostLocalInferenceReceipt(), |
| 239 | + }, |
| 240 | + rebuildSelection: n1xExpressSelection, |
| 241 | + }, |
| 242 | + { |
| 243 | + caseName: "different rebuild provider", |
| 244 | + sandboxEntry: n1xExpressEntry, |
| 245 | + rebuildSelection: { ...n1xExpressSelection, provider: "compatible-endpoint" }, |
| 246 | + }, |
| 247 | + { |
| 248 | + caseName: "different rebuild model", |
| 249 | + sandboxEntry: n1xExpressEntry, |
| 250 | + rebuildSelection: { ...n1xExpressSelection, model: "meta-llama/Llama-3.1-8B-Instruct" }, |
| 251 | + }, |
| 252 | + { |
| 253 | + caseName: "unresolved rebuild endpoint", |
| 254 | + sandboxEntry: n1xExpressEntry, |
| 255 | + rebuildSelection: { ...n1xExpressSelection, pinEndpoint: false }, |
| 256 | + }, |
| 257 | + { |
| 258 | + caseName: "noncanonical rebuild endpoint", |
| 259 | + sandboxEntry: n1xExpressEntry, |
| 260 | + rebuildSelection: { |
| 261 | + ...n1xExpressSelection, |
| 262 | + endpointUrl: "http://host.openshell.internal:8001/v1", |
| 263 | + }, |
| 264 | + }, |
| 265 | + ])( |
| 266 | + "does not infer N1x Express intent from a $caseName (#9292)", |
| 267 | + ({ sandboxEntry, rebuildSelection }) => { |
| 268 | + const recreateOptions: { allowDeferredN1xManagedVllm?: true } = {}; |
| 269 | + |
| 270 | + stageRecordedManagedVllmIntent(recreateOptions, sandboxEntry, rebuildSelection); |
| 271 | + |
| 272 | + expect(recreateOptions).not.toHaveProperty("allowDeferredN1xManagedVllm"); |
| 273 | + }, |
| 274 | + ); |
| 275 | +}); |
| 276 | + |
124 | 277 | describe("stageRebuildBaseImageResolutionHandoff", () => { |
125 | 278 | it("binds outer resolver provenance to its immutable local handoff (#7144)", () => { |
126 | 279 | const imageId = `sha256:${"a".repeat(64)}`; |
|
0 commit comments