-
Notifications
You must be signed in to change notification settings - Fork 1.3k
fix(codex): preserve Daybreak access programs in native catalog #5898
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
Closed
clairernovotny
wants to merge
6
commits into
lidge-jun:dev
from
clairernovotny:fix/daybreak-access-program-metadata
Closed
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
3abf077
fix(codex): preserve live access programs in catalog
clairernovotny d6d840c
fix: address PR 5898 access program review feedback
clairernovotny 7d9d93e
test: classify PR 5898 catalog regressions
clairernovotny 5723514
test: keep entitlement regressions below file size ratchet
clairernovotny ef95e4c
docs(codex): explain access-program catalog contracts
clairernovotny 21968b0
Merge branch 'dev' into fix/daybreak-access-program-metadata
clairernovotny 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,50 @@ | ||
| import { isMainCodexAccountTarget } from "../account-namespaces"; | ||
| import { COMBO_NAMESPACE } from "../../combos"; | ||
| import { MAIN_CODEX_ACCOUNT_ID } from "../main-account"; | ||
| import type { CodexModelEntitlementSnapshot } from "../model-entitlements"; | ||
| import { trustedAccountBoundNativeCatalogSlug } from "./account-models"; | ||
| import { isNativeAliasCatalogEntry, SUPPORTED_NATIVE_OPENAI_SLUGS } from "./metadata"; | ||
| import type { RawEntry } from "./parsing"; | ||
|
|
||
| /** Project authenticated account metadata onto native rows only. */ | ||
| export function applyNativeAccessPrograms( | ||
| entries: RawEntry[], | ||
| snapshot: CodexModelEntitlementSnapshot, | ||
| accountTargets: ReadonlyMap<string, string>, | ||
| ): void { | ||
| for (const entry of entries) { | ||
| // A combo may deliberately claim a bare native slug. It is still a routed combo row, | ||
| // so the matching native Codex roster must not project its access programs onto it. | ||
| if (isNativeAliasCatalogEntry(entry)) continue; | ||
| if (entry.owned_by === COMBO_NAMESPACE) { | ||
| delete entry.available_access_programs; | ||
| continue; | ||
| } | ||
| const accountBoundSlug = trustedAccountBoundNativeCatalogSlug(entry); | ||
| const bareSlug = typeof entry.slug === "string" && !entry.slug.includes("/") | ||
| && SUPPORTED_NATIVE_OPENAI_SLUGS.has(entry.slug) ? entry.slug : undefined; | ||
| const slug = accountBoundSlug ?? bareSlug; | ||
| if (!slug) continue; | ||
| const selector = accountBoundSlug && typeof entry.slug === "string" | ||
| ? entry.slug.slice(0, entry.slug.indexOf("/")) : undefined; | ||
| const target = selector === undefined ? MAIN_CODEX_ACCOUNT_ID : accountTargets.get(selector); | ||
| const accountId = target && isMainCodexAccountTarget(target) ? MAIN_CODEX_ACCOUNT_ID : target; | ||
| if (!accountId) { | ||
| delete entry.available_access_programs; | ||
| continue; | ||
| } | ||
| // An old on-disk catalog can contain metadata from a previous credential. Until this | ||
| // account has a confirmed roster, that value is no longer evidence of a grant. | ||
| if (!snapshot.confirmedAccountIds.has(accountId) | ||
| || !snapshot.modelsByAccount.get(accountId)?.has(slug)) { | ||
| delete entry.available_access_programs; | ||
| continue; | ||
| } | ||
| const accountPrograms = snapshot.accessProgramsByAccount?.get(accountId); | ||
| if (accountPrograms?.has(slug)) { | ||
| entry.available_access_programs = accountPrograms.get(slug) ?? null; | ||
| } else { | ||
| delete entry.available_access_programs; | ||
| } | ||
| } | ||
| } | ||
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
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
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.