Repository navigation
fix(catalog): discover new native models from the live Codex roster and refresh by default #6285
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
a3a3942
fix(catalog): discover unpinned native models and refresh the catalog…
lidge-jun 69a54f2
fix(catalog): keep default refresh to managed Codex installs and hard…
lidge-jun 396d876
fix(catalog): guard late discovery publication and document the condi…
lidge-jun File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,71 @@ | ||
| import type { OcxConfig } from "../types"; | ||
|
|
||
| const SOURCE_WAIT_MS = 15_000; | ||
| const PROCESS_WAIT_MS = 1_000; | ||
|
|
||
| /** | ||
| * A source failure or slow roster must not prevent publication from existing evidence. The signal | ||
| * aborts when the wait bound passes or the step ends, so a late source cannot publish afterwards. | ||
| */ | ||
| async function bestEffortSource(step: (active: () => boolean, signal: AbortSignal) => Promise<unknown>): Promise<void> { | ||
| let timer: ReturnType<typeof setTimeout> | undefined; | ||
| let active = true; | ||
| const controller = new AbortController(); | ||
| try { | ||
| await Promise.race([ | ||
| Promise.resolve().then(() => step(() => active, controller.signal)), | ||
| new Promise<void>(resolve => { | ||
| timer = setTimeout(resolve, SOURCE_WAIT_MS); | ||
| timer.unref?.(); | ||
| }), | ||
| ]); | ||
| } catch { | ||
| // Convergence can still use the last confirmed source snapshots. | ||
| } finally { | ||
| active = false; | ||
| controller.abort(); | ||
| clearTimeout(timer); | ||
| } | ||
| } | ||
|
|
||
| /** Settle source observations before admission captures them; gather itself never probes. */ | ||
| export async function refreshCatalogAutoRefreshSources( | ||
| config: OcxConfig, | ||
| current: () => boolean, | ||
| ): Promise<void> { | ||
| // Runtime selection also supplies the roster's trusted client version after an upgrade. | ||
| await bestEffortSource(async active => { | ||
| const { loadBundledCodexCatalog } = await import("./catalog/bundled"); | ||
| if (active() && current()) loadBundledCodexCatalog(); | ||
| // The synchronous loader bounds its selected-runtime subprocess probes itself. | ||
| }); | ||
| if (!current()) return; | ||
| await bestEffortSource(async active => { | ||
| const { ensureCodexEntitlementFreshness } = await import("./model-entitlements"); | ||
| if (active() && current()) await ensureCodexEntitlementFreshness(config, { waitMs: SOURCE_WAIT_MS }); | ||
| }); | ||
| if (!current()) return; | ||
| // The entitlement roster above is asked under the installed client version, which upstream's | ||
| // rollout gate can hide a new model from (GPT-6.1 Sol was invisible to 0.158 on release day). | ||
| // Discovery asks as a newer client so an unpinned native reaches the converge below. | ||
| await bestEffortSource(async (active, signal) => { | ||
| const { discoverCodexNativeRoster } = await import("./model-entitlements"); | ||
| // A stopped scheduler generation aborts too, so a stale tick cannot record discoveries. | ||
| if (active() && current()) await discoverCodexNativeRoster(config, { signal, isCurrent: () => active() && current() }); | ||
| }); | ||
| } | ||
|
|
||
| /** Observation only: running sessions own static copies and require an operator restart. */ | ||
| export async function catalogAutoRefreshReloadRequired(changed = true): Promise<boolean> { | ||
| try { | ||
| const { listCodexAppServerProcesses, collectCodexAppServerCatalogStateWithin } = await import("./app-server-processes"); | ||
| // A cold Windows start-time walk can miss a short deadline. The changed-set hint | ||
| // needs only the bounded process listing, so it does not depend on that walk. | ||
| if (changed) return listCodexAppServerProcesses().length > 0; | ||
| const status = await collectCodexAppServerCatalogStateWithin(PROCESS_WAIT_MS); | ||
| return status.state === "stale" || status.state === "unknown"; | ||
| } catch { | ||
| // Failure to observe a restart cannot clear a previously recorded requirement. | ||
| return !changed; | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.