GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix(acp-registry): preserve explicit singleton catalogs, provisional … · pingdotgg/t3code@92ac0ed

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • packages/provider-acp-registry/src/server
    • driver.test.ts
    • driver.ts
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎packages/provider-acp-registry/src/server/driver.test.ts‎

Copy file name to clipboardExpand all lines: packages/provider-acp-registry/src/server/driver.test.ts
+196-2Lines changed: 196 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -784,6 +784,36 @@ describe("acpRegistrySnapshotReadiness", () => {
784784
expect(entitled.models.map((m) => m.slug)).toEqual(["gmodel"]);
785785
expect(entitled.models.find((m) => m.slug === "gmodel")?.isDefault).toBe(true);
786786

787+
const afterProvisional = applyAcpRegistryLiveConfiguration(
788+
entitled,
789+
{
790+
models: [{ id: "placeholder", name: "Placeholder", description: null }],
791+
currentModelId: "placeholder",
792+
configOptions: [],
793+
modelsFromModelSelect: false,
794+
},
795+
[],
796+
entitled.models,
797+
{ preserveSingleModelCatalog: true },
798+
);
799+
expect(afterProvisional.models.map((m) => m.slug)).toEqual(["gmodel"]);
800+
expect(afterProvisional.models.find((m) => m.slug === "gmodel")?.isDefault).toBe(true);
801+
802+
const replacedExplicit = applyAcpRegistryLiveConfiguration(
803+
entitled,
804+
{
805+
models: [{ id: "hmodel", name: "Haiku-Only", description: null }],
806+
currentModelId: "hmodel",
807+
configOptions: [],
808+
modelsFromModelSelect: true,
809+
},
810+
[],
811+
entitled.models,
812+
{ preserveSingleModelCatalog: true },
813+
);
814+
expect(replacedExplicit.models.map((m) => m.slug)).toEqual(["hmodel"]);
815+
expect(replacedExplicit.models.find((m) => m.slug === "hmodel")?.isDefault).toBe(true);
816+
787817
const narrowed = applyAcpRegistryLiveConfiguration(
788818
provider,
789819
{
@@ -831,6 +861,31 @@ describe("acpRegistryEnrichmentCache", () => {
831861

832862
expect(replayed).toBe(cache);
833863
expect(replayed.entry?.expiresAt).toBe(1_000);
864+
865+
const explicitSingletonCache = {
866+
generation: 1,
867+
entry: {
868+
provider: providerWithModels(
869+
[{ id: "gmodel", name: "GPT-Pro", description: null }],
870+
"gmodel",
871+
),
872+
expiresAt: 1_000,
873+
},
874+
};
875+
const provisionalUpdate = updateAcpRegistryEnrichmentCache({
876+
cache: explicitSingletonCache,
877+
configuration: {
878+
models: [{ id: "placeholder", name: "Placeholder", description: null }],
879+
currentModelId: "placeholder",
880+
configOptions: [],
881+
modelsFromModelSelect: false,
882+
},
883+
customModels: [],
884+
now: 2_000,
885+
preserveSingleModelCatalog: true,
886+
});
887+
expect(provisionalUpdate).toBe(explicitSingletonCache);
888+
expect(provisionalUpdate.entry?.provider.models.map((m) => m.slug)).toEqual(["gmodel"]);
834889
});
835890

836891
it("updates the cache and promotes the expiry when live configuration discovers a catalog", () => {
@@ -1036,6 +1091,13 @@ createInterface({ input: process.stdin }).on("line", (line) => {
10361091
});
10371092
return;
10381093
}
1094+
if (payload && !Array.isArray(payload) && typeof payload.fail === "string") {
1095+
send({
1096+
id,
1097+
error: { code: payload.code ?? -32603, message: payload.fail },
1098+
});
1099+
return;
1100+
}
10391101
const availableModels = payload.map((entry) =>
10401102
typeof entry === "string" ? { modelId: entry, name: entry } : entry,
10411103
);
@@ -1492,6 +1554,56 @@ it.layer(driverLayer)("AcpRegistryDriver periodic refresh", (it) => {
14921554
Option.getOrThrow(yield* Fiber.join(afterProvisional)).models.map((model) => model.slug),
14931555
).toEqual(["new-model", "old-model", "other-model"]);
14941556

1557+
// A provisional probe must still use the short retry TTL even when it retains a multi-model catalog.
1558+
yield* fileSystem.writeFileString(
1559+
modelsPath,
1560+
JSON.stringify(["new-model", "old-model", "other-model", "settled-model"]),
1561+
);
1562+
yield* TestClock.adjust("1 minute");
1563+
const afterProvisionalRetry = yield* waitForEnriched().pipe(
1564+
Effect.forkScoped({ startImmediately: true }),
1565+
);
1566+
yield* instance.snapshot.refresh;
1567+
expect(
1568+
Option.getOrThrow(yield* Fiber.join(afterProvisionalRetry)).models.map(
1569+
(model) => model.slug,
1570+
),
1571+
).toEqual(["new-model", "old-model", "other-model", "settled-model"]);
1572+
1573+
// A transient discovery failure after TTL expiry must surface warning status without
1574+
// dropping the accepted catalog to synthetic default, and must stay uncached for retry.
1575+
yield* fileSystem.writeFileString(
1576+
modelsPath,
1577+
JSON.stringify({ fail: "Temporary discovery outage" }),
1578+
);
1579+
yield* TestClock.adjust("16 minutes");
1580+
const failedProbe = yield* instance.snapshot.streamChanges.pipe(
1581+
Stream.filter((snapshot) => snapshot.status === "warning"),
1582+
Stream.runHead,
1583+
Effect.forkScoped({ startImmediately: true }),
1584+
);
1585+
yield* instance.snapshot.refresh;
1586+
const warned = Option.getOrThrow(yield* Fiber.join(failedProbe));
1587+
expect(warned.status).toBe("warning");
1588+
expect(warned.models.map((model) => model.slug)).toEqual([
1589+
"new-model",
1590+
"old-model",
1591+
"other-model",
1592+
"settled-model",
1593+
]);
1594+
1595+
yield* fileSystem.writeFileString(
1596+
modelsPath,
1597+
JSON.stringify(["new-model", "old-model", "other-model", "settled-model"]),
1598+
);
1599+
const recovered = yield* waitForEnriched().pipe(
1600+
Effect.forkScoped({ startImmediately: true }),
1601+
);
1602+
yield* instance.snapshot.refresh;
1603+
expect(
1604+
Option.getOrThrow(yield* Fiber.join(recovered)).models.map((model) => model.slug),
1605+
).toEqual(["new-model", "old-model", "other-model", "settled-model"]);
1606+
14951607
// Readiness must keep the last accepted catalog when enrichment is skipped during foreground startup,
14961608
// and drop that fallback once caches are invalidated.
14971609
const startupEntered = yield* Deferred.make<void>();
@@ -1511,6 +1623,7 @@ it.layer(driverLayer)("AcpRegistryDriver periodic refresh", (it) => {
15111623
"new-model",
15121624
"old-model",
15131625
"other-model",
1626+
"settled-model",
15141627
]);
15151628

15161629
yield* instance.invalidateCaches ?? Effect.void;
@@ -1615,6 +1728,55 @@ it.layer(driverLayer)("AcpRegistryDriver periodic refresh", (it) => {
16151728
(config) => config.currentModelId,
16161729
),
16171730
).toEqual(Option.some("entitled-model"));
1731+
1732+
// A subsequent provisional single-model live update must not replace the explicit singleton
1733+
// catalog or downgrade its provenance.
1734+
const provisionalProcessed = yield* instance.snapshot.streamChanges.pipe(
1735+
Stream.filter(
1736+
(snapshot) =>
1737+
snapshot.models
1738+
.find((model) => model.slug === "entitled-model")
1739+
?.capabilities?.optionDescriptors?.some((option) => option.id === "effort") === true,
1740+
),
1741+
Stream.runHead,
1742+
Effect.forkScoped({ startImmediately: true }),
1743+
);
1744+
yield* coordinator.publishLiveConfiguration(identity.instanceId, {
1745+
models: [{ id: "live-placeholder", name: "Live Placeholder", description: null }],
1746+
currentModelId: "live-placeholder",
1747+
configOptions: [
1748+
{
1749+
id: "effort",
1750+
label: "Effort",
1751+
type: "select",
1752+
currentValue: "high",
1753+
options: [
1754+
{ id: "low", label: "Low" },
1755+
{ id: "high", label: "High" },
1756+
],
1757+
},
1758+
],
1759+
modelsFromModelSelect: false,
1760+
});
1761+
expect(
1762+
Option.getOrThrow(yield* Fiber.join(provisionalProcessed)).models.map(
1763+
(model) => model.slug,
1764+
),
1765+
).toEqual(["entitled-model"]);
1766+
1767+
yield* fileSystem.writeFileString(modelsPath, JSON.stringify({ provisional: "placeholder" }));
1768+
yield* TestClock.adjust("16 minutes");
1769+
const afterProvisionalProbe = yield* instance.snapshot.streamChanges.pipe(
1770+
Stream.filter((snapshot) => snapshot.nativeSessions !== undefined),
1771+
Stream.runHead,
1772+
Effect.forkScoped({ startImmediately: true }),
1773+
);
1774+
yield* instance.snapshot.refresh;
1775+
expect(
1776+
Option.getOrThrow(yield* Fiber.join(afterProvisionalProbe)).models.map(
1777+
(model) => model.slug,
1778+
),
1779+
).toEqual(["entitled-model"]);
16181780
}),
16191781
);
16201782

@@ -1636,6 +1798,9 @@ it.layer(driverLayer)("AcpRegistryDriver periodic refresh", (it) => {
16361798
const staleCallbackEntered = yield* Deferred.make<void>();
16371799
const releaseStaleCallback = yield* Deferred.make<void>();
16381800
const staleCallbackDone = yield* Deferred.make<void>();
1801+
const newerCallbackEntered = yield* Deferred.make<void>();
1802+
const releaseNewerCallback = yield* Deferred.make<void>();
1803+
const newerCallbackDone = yield* Deferred.make<void>();
16391804
const secondWatcherSubscribed = yield* Deferred.make<void>();
16401805
let postTtlLiveReads = 0;
16411806
let armed = false;
@@ -1672,7 +1837,14 @@ it.layer(driverLayer)("AcpRegistryDriver periodic refresh", (it) => {
16721837
Effect.andThen(Deferred.succeed(staleCallbackDone, undefined)),
16731838
Effect.asVoid,
16741839
)
1675-
: onUpdate(configuration, revision),
1840+
: configuration.currentModelId === "newer-live-model"
1841+
? Deferred.succeed(newerCallbackEntered, undefined).pipe(
1842+
Effect.andThen(Deferred.await(releaseNewerCallback)),
1843+
Effect.andThen(onUpdate(configuration, revision)),
1844+
Effect.andThen(Deferred.succeed(newerCallbackDone, undefined)),
1845+
Effect.asVoid,
1846+
)
1847+
: onUpdate(configuration, revision),
16761848
options,
16771849
);
16781850
}),
@@ -1746,6 +1918,19 @@ it.layer(driverLayer)("AcpRegistryDriver periodic refresh", (it) => {
17461918
Option.getOrThrow(yield* Fiber.join(probed)).models.map((model) => model.slug),
17471919
).toEqual(["old-model", "other-model", "new-model"]);
17481920

1921+
// Publish a newer live revision while the stale callback is still paused so currentLive is
1922+
// Option.some(newer) when the stale callback resumes, specifically exercising the
1923+
// clearedThroughRevision watermark.
1924+
yield* coordinator.publishLiveConfiguration(identity.instanceId, {
1925+
models: [
1926+
{ id: "old-model", name: "old-model", description: null },
1927+
{ id: "newer-live-model", name: "newer-live-model", description: null },
1928+
],
1929+
currentModelId: "newer-live-model",
1930+
configOptions: [],
1931+
modelsFromModelSelect: true,
1932+
});
1933+
17491934
// Releasing the delayed watcher callback must not overwrite the snapshot, cache, or accepted catalog.
17501935
yield* Deferred.succeed(releaseStaleCallback, undefined);
17511936
yield* Deferred.await(staleCallbackDone);
@@ -1755,6 +1940,15 @@ it.layer(driverLayer)("AcpRegistryDriver periodic refresh", (it) => {
17551940
"new-model",
17561941
]);
17571942

1943+
// The newer live revision queued behind it must still be applied.
1944+
yield* Deferred.await(newerCallbackEntered);
1945+
yield* Deferred.succeed(releaseNewerCallback, undefined);
1946+
yield* Deferred.await(newerCallbackDone);
1947+
expect((yield* instance.snapshot.getSnapshot).models.map((model) => model.slug)).toEqual([
1948+
"old-model",
1949+
"newer-live-model",
1950+
]);
1951+
17581952
yield* fileSystem.writeFileString(
17591953
modelsPath,
17601954
JSON.stringify(["unexpected-reprobe", "other-model"]),
@@ -1763,7 +1957,7 @@ it.layer(driverLayer)("AcpRegistryDriver periodic refresh", (it) => {
17631957
yield* instance.snapshot.refresh;
17641958
expect(
17651959
Option.getOrThrow(yield* Fiber.join(cached)).models.map((model) => model.slug),
1766-
).toEqual(["old-model", "other-model", "new-model"]);
1960+
).toEqual(["old-model", "newer-live-model"]);
17671961
}),
17681962
);
17691963
});

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.