fix(antigravity): refresh the model manifest so older Gemini models fold as legacy (#9397)
Co-authored-by: Claude Fable 5.1 <[email protected]>
This commit is contained in:
1 parent
19c97ea56d
commit
1e05187309
5 files changed
+81
-3
No files matched your search
@@ -248,7 +248,11 @@ export const AntigravityDriver: ProviderDriver<AntigravitySettings, AntigravityD
|
||||
usesBrowser: antigravityAuthUsesBrowser(auth.authMethod),
|
||||
});
|
||||
|
||||
// Kick the TTL-gated manifest refresh alongside the health check, as
|
||||
// Codex and Claude do. Without it an environment that only runs
|
||||
// Antigravity would keep classifying against a stale disk cache.
|
||||
const probe = Effect.gen(function* () {
|
||||
yield* modelManifest.refreshInBackground;
|
||||
const processScope = yield* Scope.make();
|
||||
yield* Effect.addFinalizer((exit) => Scope.close(processScope, exit));
|
||||
return yield* authFlow
|
||||
|
||||
@@ -2,7 +2,9 @@ import { assert, describe, it } from "@effect/vitest";
|
||||
import * as NodeServices from "@effect/platform-node/NodeServices";
|
||||
import { ProviderDriverKind, type ServerProviderModel } from "@t3tools/contracts";
|
||||
import * as Effect from "effect/Effect";
|
||||
import * as FileSystem from "effect/FileSystem";
|
||||
import * as Layer from "effect/Layer";
|
||||
import * as Path from "effect/Path";
|
||||
import * as TestClock from "effect/testing/TestClock";
|
||||
import { HttpClient, HttpClientResponse } from "effect/unstable/http";
|
||||
|
||||
@@ -15,6 +17,8 @@ import {
|
||||
make,
|
||||
resolveProviderCatalog,
|
||||
type ModelManifestData,
|
||||
manifestUpdatedAtMs,
|
||||
encodeManifestCache,
|
||||
} from "./ModelManifest.ts";
|
||||
|
||||
/**
|
||||
@@ -186,8 +190,12 @@ describe("resolveProviderCatalog", () => {
|
||||
});
|
||||
});
|
||||
|
||||
// Remote fixtures date after the bundle so a fetch still outranks it.
|
||||
const REMOTE_UPDATED_AT = "2099-01-01T00:00:00Z";
|
||||
|
||||
const REMOTE_MANIFEST: ModelManifestData = {
|
||||
version: 1,
|
||||
updatedAt: REMOTE_UPDATED_AT,
|
||||
currentModels: {
|
||||
codex: ["remote-model"],
|
||||
claudeAgent: ["remote-agent-model"],
|
||||
@@ -196,6 +204,7 @@ const REMOTE_MANIFEST: ModelManifestData = {
|
||||
|
||||
const REMOTE_CLAUDE_MANIFEST: ModelManifestData = {
|
||||
version: 1,
|
||||
updatedAt: REMOTE_UPDATED_AT,
|
||||
currentModels: {},
|
||||
providers: {
|
||||
claudeAgent: {
|
||||
@@ -368,6 +377,47 @@ describe("ModelManifest service", () => {
|
||||
);
|
||||
});
|
||||
|
||||
it.live("drops a disk cache of a manifest older than the bundled one", () =>
|
||||
Effect.gen(function* () {
|
||||
const fs = yield* FileSystem.FileSystem;
|
||||
const path = yield* Path.Path;
|
||||
const config = yield* ServerConfig.ServerConfig;
|
||||
assert.isAbove(manifestUpdatedAtMs(BUNDLED_MODEL_MANIFEST), 0);
|
||||
const cachePath = path.join(config.stateDir, "model-manifest.json");
|
||||
// A cache of the manifest as it was before the release edited it. The
|
||||
// fetch time is irrelevant: the remote may be unreachable now, so
|
||||
// `current` must already prefer the bundle.
|
||||
const { updatedAt: _undated, ...undatedManifest } = REMOTE_MANIFEST;
|
||||
for (const stale of [
|
||||
undatedManifest,
|
||||
{ ...REMOTE_MANIFEST, updatedAt: "2000-01-01T00:00:00Z" },
|
||||
]) {
|
||||
yield* fs.writeFileString(
|
||||
cachePath,
|
||||
yield* encodeManifestCache({ fetchedAtMs: 0, manifest: stale }),
|
||||
);
|
||||
const service = yield* make;
|
||||
assert.deepStrictEqual(yield* service.current, BUNDLED_MODEL_MANIFEST);
|
||||
}
|
||||
|
||||
// A cache of a newer edit still outranks the bundle.
|
||||
yield* fs.writeFileString(
|
||||
cachePath,
|
||||
yield* encodeManifestCache({ fetchedAtMs: 0, manifest: REMOTE_MANIFEST }),
|
||||
);
|
||||
const later = yield* make;
|
||||
assert.deepStrictEqual(yield* later.current, REMOTE_MANIFEST);
|
||||
}).pipe(
|
||||
Effect.scoped,
|
||||
Effect.provide(
|
||||
serviceLayers({
|
||||
prefix: "model-manifest-newer-bundle-test",
|
||||
response: () => Response.json(REMOTE_MANIFEST),
|
||||
}),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
it.live("does not fetch when provider update checks are disabled", () =>
|
||||
Effect.gen(function* () {
|
||||
let fetchCount = 0;
|
||||
|
||||
@@ -82,6 +82,12 @@ const ManifestProviderCatalog = Schema.Struct({
|
||||
*/
|
||||
const ModelManifestEnvelopeSchema = Schema.Struct({
|
||||
version: Schema.Literal(1),
|
||||
/**
|
||||
* ISO date of the last edit. A release bundles its manifest, and a disk
|
||||
* cache of an older edit must not outrank it. Optional so older remote
|
||||
* files still decode; they count as older than any dated bundle.
|
||||
*/
|
||||
updatedAt: Schema.optional(Schema.String),
|
||||
currentModels: Schema.Record(Schema.String, Schema.Array(Schema.String)),
|
||||
providers: Schema.optional(Schema.Record(Schema.String, ManifestProviderCatalog)),
|
||||
});
|
||||
@@ -131,6 +137,13 @@ const decodeManifest = Schema.decodeUnknownEffect(ModelManifestSchema);
|
||||
export const BUNDLED_MODEL_MANIFEST: ModelManifestData =
|
||||
Schema.decodeUnknownSync(ModelManifestSchema)(bundledManifestJson);
|
||||
|
||||
/** Epoch millis of the manifest's `updatedAt`, or 0 when absent or unparsable. */
|
||||
export function manifestUpdatedAtMs(manifest: ModelManifestData): number {
|
||||
if (manifest.updatedAt === undefined) return 0;
|
||||
const parsed = Date.parse(manifest.updatedAt);
|
||||
return Number.isNaN(parsed) ? 0 : parsed;
|
||||
}
|
||||
|
||||
/** Resolve provider-neutral model presentation and capability data. */
|
||||
export function resolveProviderCatalog(
|
||||
manifest: ModelManifestData,
|
||||
@@ -186,7 +199,8 @@ const decodeManifestCache = Schema.decodeUnknownEffect(
|
||||
ManifestCacheFile as unknown as Schema.Codec<typeof ManifestCacheFile.Type>,
|
||||
),
|
||||
);
|
||||
const encodeManifestCache = Schema.encodeEffect(
|
||||
/** Exported for tests that seed the disk cache. */
|
||||
export const encodeManifestCache = Schema.encodeEffect(
|
||||
Schema.fromJsonString(
|
||||
ManifestCacheFile as unknown as Schema.Codec<typeof ManifestCacheFile.Type>,
|
||||
),
|
||||
@@ -330,7 +344,14 @@ export const make = Effect.gen(function* () {
|
||||
);
|
||||
if (fromDisk === null) return;
|
||||
// The disk copy is the last-seen remote manifest, so it outranks the
|
||||
// bundle even when stale: it is refreshed on the next successful fetch.
|
||||
// bundle even when stale, unless the bundle's own edit date is newer
|
||||
// than the cached manifest's. Then the release carries data the cache
|
||||
// has not seen and the cache is dropped so the next refresh replaces
|
||||
// it. Comparing edit dates, not fetch time, keeps this independent of
|
||||
// when the cache was written relative to the release.
|
||||
if (manifestUpdatedAtMs(BUNDLED_MODEL_MANIFEST) > manifestUpdatedAtMs(fromDisk.manifest)) {
|
||||
return;
|
||||
}
|
||||
manifest = fromDisk.manifest;
|
||||
fetchedAtMs = fromDisk.fetchedAtMs;
|
||||
}),
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
{
|
||||
"version": 1,
|
||||
"updatedAt": "2026-09-03T09:58:00Z",
|
||||
"currentModels": {
|
||||
"codex": [
|
||||
"gpt-5.6-luna",
|
||||
|
||||
@@ -3,7 +3,9 @@
|
||||
`apps/server/src/provider/model-manifest.json` is bundled for offline startup and fetched from
|
||||
`main` at runtime. A remote fetch replaces the in-memory and on-disk cache only after generic
|
||||
catalog references and provider-owned adapter data validate. A failed or invalid fetch keeps the
|
||||
last successful remote manifest. The bundle is used only when no valid remote cache exists.
|
||||
last successful remote manifest. The bundle is used when no valid remote cache exists, or when
|
||||
the bundle's `updatedAt` is later than the cached manifest's, so a release that edits the manifest
|
||||
takes effect before the next successful fetch. Bump `updatedAt` whenever you edit the file.
|
||||
|
||||
The top-level provider catalog is generic: models contain presentation metadata, aliases, status,
|
||||
an optional badge, and a reusable capability profile. The profile and model `adapter` fields are
|
||||
|
||||
Reference in new issue
Block a user