Skip to content

Commit ee191f3

Browse files
committed
fix(server): provider updates check compatibility against a fresh latest version
An unpinned update installs whatever the installer offers when it runs, so the runner drops the cached latest version before its compatibility check. Before Homebrew's answer moved into the shared cache, fresh resolution reran `brew info` here; without this a release marked broken could be installed behind an hour-old supported answer.
1 parent 0b6d1e3 commit ee191f3

2 files changed

Lines changed: 61 additions & 1 deletion

File tree

‎apps/server/src/provider/providerMaintenanceRunner.test.ts‎

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -988,6 +988,63 @@ describe("providerMaintenanceRunner", () => {
988988
});
989989
});
990990

991+
it.effect("checks compatibility against the installer's current latest, not a cached one", () => {
992+
const calls: string[] = [];
993+
const manifest: ModelManifest.ModelManifestData = {
994+
version: 1,
995+
currentModels: {},
996+
compatibility: [
997+
{
998+
driver: "codex",
999+
t3CodeRange: ">=0.0.42",
1000+
ranges: [
1001+
{ range: "<=2.0.0", status: "supported" },
1002+
{ range: ">2.0.0", status: "broken" },
1003+
],
1004+
},
1005+
],
1006+
};
1007+
return Effect.gen(function* () {
1008+
const { registry } = yield* makeRegistry();
1009+
const brewLatest = yield* Ref.make("2.0.0");
1010+
const capabilities = makeProviderMaintenanceCapabilities({
1011+
provider: CODEX_DRIVER,
1012+
packageName: "@openai/codex",
1013+
updateExecutable: "/opt/homebrew/bin/brew",
1014+
updateArgs: ["upgrade", "--cask", "codex"],
1015+
updateLockKey: "homebrew",
1016+
latestVersion: null,
1017+
lookupLatestVersion: Ref.get(brewLatest),
1018+
});
1019+
const updater = yield* makeTestRunner(
1020+
{
1021+
...registry,
1022+
getProviderMaintenanceCapabilitiesForInstance: () => Effect.succeed(capabilities),
1023+
},
1024+
manifest,
1025+
);
1026+
// Verifying this update caches Homebrew's answer, 2.0.0.
1027+
yield* updater.updateProvider(CODEX_DRIVER);
1028+
assert.deepStrictEqual(calls, ["upgrade --cask codex"]);
1029+
1030+
yield* Ref.set(brewLatest, "3.0.0");
1031+
const refused = yield* updater.updateProvider(CODEX_DRIVER);
1032+
assert.strictEqual(refused.providers[0]?.updateState?.status, "failed");
1033+
assert.deepStrictEqual(calls, ["upgrade --cask codex"]);
1034+
}).pipe(
1035+
Effect.provide(
1036+
Layer.mergeAll(
1037+
layerNonWindowsPlatform,
1038+
layerLatestVersionHttpClient("9.9.9"),
1039+
layerMockSpawner((_command, args) => {
1040+
calls.push(args.join(" "));
1041+
return { stdout: "upgraded" };
1042+
}),
1043+
),
1044+
),
1045+
);
1046+
});
1047+
9911048
it.effect("refuses incompatible latest versions and unapproved or unpinnable targets", () => {
9921049
const calls: string[] = [];
9931050
const manifest: ModelManifest.ModelManifestData = {

‎apps/server/src/provider/providerMaintenanceRunner.ts‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -460,9 +460,12 @@ export const make = Effect.fn("ProviderMaintenanceRunner.make")(function* () {
460460
}
461461

462462
const manifest = yield* manifestService.current;
463+
// An unpinned update installs whatever the installer offers now,
464+
// so the compatibility check reads it fresh, not from the cache.
463465
const candidateVersion =
464466
targetVersion ??
465-
(yield* resolveLatestProviderVersion(fresh).pipe(
467+
(yield* invalidateLatestProviderVersion(fresh).pipe(
468+
Effect.andThen(resolveLatestProviderVersion(fresh)),
466469
Effect.provideService(HttpClient.HttpClient, httpClient),
467470
Effect.provideService(
468471
ProviderLatestVersions.ProviderLatestVersions,

0 commit comments

Comments
 (0)