Skip to content

Commit 058d004

Browse files
committed
fix(providers): reject withdrawn runtimes after reinstall validation
1 parent 233213d commit 058d004

4 files changed

Lines changed: 101 additions & 59 deletions

File tree

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

Lines changed: 33 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -950,26 +950,39 @@ it.layer(NodeServices.layer)("Antigravity installation", (it) => {
950950
}),
951951
);
952952

953-
it.effect("preserves the active runtime when an update is withdrawn during validation", () =>
954-
Effect.gen(function* () {
955-
let manifest = ModelManifest.BUNDLED_MODEL_MANIFEST;
956-
const h = yield* makeHarness({
957-
asset: yield* pinnedAsset(),
958-
registry: registryListing(),
959-
archives: { [upstreamUrl]: upstreamArchive },
960-
manifest: Effect.sync(() => manifest),
961-
validate: (_executable, version) =>
962-
Effect.sync(() => {
963-
if (version === "1.4.1") manifest = withdrawnManifest;
964-
}),
965-
});
966-
yield* h.installation.start;
967-
yield* terminalState(h.installation);
968-
yield* h.installation.checkForUpdate;
969-
yield* h.installation.start;
970-
expect((yield* terminalState(h.installation)).phase).toBe("failed");
971-
expect((yield* h.installation.resolve()).version).toBe("1.3.0");
972-
}),
953+
it.effect.each(["update", "reinstall"] as const)(
954+
"rejects withdrawal during $0 validation",
955+
(operation) =>
956+
Effect.gen(function* () {
957+
let manifest = ModelManifest.BUNDLED_MODEL_MANIFEST;
958+
let withdraw = operation === "update";
959+
const h = yield* makeHarness({
960+
asset: yield* pinnedAsset(),
961+
registry: registryListing(),
962+
archives: { [upstreamUrl]: upstreamArchive },
963+
manifest: Effect.sync(() => manifest),
964+
validate: (_executable, version) =>
965+
Effect.sync(() => {
966+
if (withdraw && version === "1.4.1") manifest = withdrawnManifest;
967+
}),
968+
});
969+
yield* h.installation.start;
970+
yield* terminalState(h.installation);
971+
yield* h.installation.checkForUpdate;
972+
if (operation === "reinstall") {
973+
yield* h.installation.start;
974+
expect((yield* terminalState(h.installation)).phase).toBe("succeeded");
975+
withdraw = true;
976+
}
977+
yield* h.installation.start;
978+
expect((yield* terminalState(h.installation)).phase).toBe("failed");
979+
if (operation === "update") {
980+
expect((yield* h.installation.resolve()).version).toBe("1.3.0");
981+
} else {
982+
expect((yield* h.installation.state).version).toBe("1.3.0");
983+
yield* Effect.flip(h.installation.resolve());
984+
}
985+
}),
973986
);
974987

975988
it.effect("returns an install the manifest withdraws to the pinned release", () =>

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

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -919,12 +919,20 @@ export const makeAntigravityInstallation = Effect.fn("AntigravityInstallation.ma
919919
Effect.scoped,
920920
Effect.timeout(VALIDATION_TIMEOUT),
921921
);
922+
const kept = yield* keptInstall(installed.version);
923+
if (kept === null) {
924+
yield* SubscriptionRef.update(state, (current) => ({ ...current, ...offer(kept) }));
925+
return yield* installationError(
926+
"verify",
927+
"This Antigravity release was withdrawn. Check for updates and try again.",
928+
);
929+
}
922930
yield* SubscriptionRef.update(
923931
state,
924932
(current) =>
925933
({
926934
...current,
927-
...offer(installed.version),
935+
...offer(kept),
928936
phase: "succeeded",
929937
installedVersion: installed.version,
930938
message: null,

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

Lines changed: 50 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -663,41 +663,54 @@ it.effect("returns a managed install the manifest withdraws to the pinned releas
663663
}).pipe(Effect.scoped, Effect.provide(NodeServices.layer)),
664664
);
665665

666-
it.effect("preserves the active runtime when an update is withdrawn during validation", () =>
667-
Effect.gen(function* () {
668-
const crypto = yield* Crypto.Crypto;
669-
const checksum = Hex.encode(
670-
yield* crypto.digest("SHA-256", upstreamArchive).pipe(Effect.orDie),
671-
);
672-
let manifest = ModelManifest.BUNDLED_MODEL_MANIFEST;
673-
const h = yield* makeHarness({
674-
responses: upstreamResponses(checksum),
675-
manifestCurrent: Effect.sync(() => manifest),
676-
options: {
677-
validate: (_executable, version) =>
678-
Effect.sync(() => {
679-
if (version === upstreamVersion)
680-
manifest = {
681-
...ModelManifest.BUNDLED_MODEL_MANIFEST,
682-
compatibility: [
683-
{
684-
driver: "codex",
685-
t3CodeRange: ">=0.0.42",
686-
ranges: [
687-
{ range: ">=0.160.0", status: "unsupported" },
688-
{ range: ">=0.156.0 <0.160.0", status: "supported" },
689-
],
690-
},
691-
],
692-
};
693-
}),
694-
},
695-
});
696-
yield* h.installation.start;
697-
yield* terminalState(h.installation);
698-
yield* h.installation.checkForUpdate;
699-
yield* h.installation.start;
700-
expect((yield* terminalState(h.installation)).phase).toBe("failed");
701-
expect((yield* h.installation.resolve()).version).toBe("0.156.1");
702-
}).pipe(Effect.scoped, Effect.provide(NodeServices.layer)),
666+
it.effect.each(["update", "reinstall"] as const)(
667+
"rejects withdrawal during $0 validation",
668+
(operation) =>
669+
Effect.gen(function* () {
670+
const crypto = yield* Crypto.Crypto;
671+
const checksum = Hex.encode(
672+
yield* crypto.digest("SHA-256", upstreamArchive).pipe(Effect.orDie),
673+
);
674+
let manifest = ModelManifest.BUNDLED_MODEL_MANIFEST;
675+
let withdraw = operation === "update";
676+
const h = yield* makeHarness({
677+
responses: upstreamResponses(checksum),
678+
manifestCurrent: Effect.sync(() => manifest),
679+
options: {
680+
validate: (_executable, version) =>
681+
Effect.sync(() => {
682+
if (withdraw && version === upstreamVersion)
683+
manifest = {
684+
...ModelManifest.BUNDLED_MODEL_MANIFEST,
685+
compatibility: [
686+
{
687+
driver: "codex",
688+
t3CodeRange: ">=0.0.42",
689+
ranges: [
690+
{ range: ">=0.160.0", status: "unsupported" },
691+
{ range: ">=0.156.0 <0.160.0", status: "supported" },
692+
],
693+
},
694+
],
695+
};
696+
}),
697+
},
698+
});
699+
yield* h.installation.start;
700+
yield* terminalState(h.installation);
701+
yield* h.installation.checkForUpdate;
702+
if (operation === "reinstall") {
703+
yield* h.installation.start;
704+
expect((yield* terminalState(h.installation)).phase).toBe("succeeded");
705+
withdraw = true;
706+
}
707+
yield* h.installation.start;
708+
expect((yield* terminalState(h.installation)).phase).toBe("failed");
709+
if (operation === "update") {
710+
expect((yield* h.installation.resolve()).version).toBe("0.156.1");
711+
} else {
712+
expect((yield* h.installation.state).version).toBe("0.156.1");
713+
yield* Effect.flip(h.installation.resolve());
714+
}
715+
}).pipe(Effect.scoped, Effect.provide(NodeServices.layer)),
703716
);

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

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -761,12 +761,20 @@ export const makeCodexInstallation = Effect.fn("makeCodexInstallation")(function
761761
Effect.scoped,
762762
Effect.timeout("90 seconds"),
763763
);
764+
const kept = yield* keptInstall(executable.version);
765+
if (kept === null) {
766+
yield* SubscriptionRef.update(state, (current) => ({ ...current, ...offer(kept) }));
767+
return yield* installationError(
768+
"verify",
769+
"This Codex release was withdrawn. Check for updates and try again.",
770+
);
771+
}
764772
yield* SubscriptionRef.update(
765773
state,
766774
(current) =>
767775
({
768776
...current,
769-
...offer(executable.version),
777+
...offer(kept),
770778
phase: "succeeded",
771779
source: "managed",
772780
installedVersion: executable.version,

0 commit comments

Comments
 (0)