Skip to content

Commit 3ad317c

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 b08e0f9 commit 3ad317c

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
@@ -980,6 +980,63 @@ describe("providerMaintenanceRunner", () => {
980980
});
981981
});
982982

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

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

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

451451
const manifest = yield* manifestService.current;
452+
// An unpinned update installs whatever the installer offers now,
453+
// so the compatibility check reads it fresh, not from the cache.
452454
const candidateVersion =
453455
targetVersion ??
454-
(yield* resolveLatestProviderVersion(fresh).pipe(
456+
(yield* invalidateLatestProviderVersion(fresh).pipe(
457+
Effect.andThen(resolveLatestProviderVersion(fresh)),
455458
Effect.provideService(HttpClient.HttpClient, httpClient),
456459
Effect.provideService(
457460
ProviderLatestVersions.ProviderLatestVersions,

0 commit comments

Comments
 (0)