-
Notifications
You must be signed in to change notification settings - Fork 873
feat(catalog): apply configured auto_review_model override during sync #2363
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
base: dev
Are you sure you want to change the base?
Changes from all commits
076cf91
0f84fe9
002f012
3bfd0c0
a68a2bf
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -41,7 +41,7 @@ import { | |
| } from "../model-entitlements"; | ||
|
|
||
|
|
||
| import { CODEX_CUSTOM_MODEL_CATALOG_KIND, CODEX_PROVIDER_MODEL_CATALOG_KIND, activeCodexModelsCachePath, applyCatalogMetadata, applyMultiAgentMode, applyNativeOpenAiContextOverride, applyRoutedCodexToolMode, catalogBackupPathFor, catalogHasRoutedEntries, catalogModelSlug, ensureStrictCatalogFields, findNativeTemplate, isDefaultCatalogPath, isRoutedModelCompatibilityExcluded, legacyCatalogBackupPath, normalizeRoutedCatalogEntry, normalizeServiceTiers, readCatalog, readCatalogBackup, readCodexCatalogPath, readNativeBaseline } from "./parsing"; | ||
| import { CODEX_CUSTOM_MODEL_CATALOG_KIND, CODEX_PROVIDER_MODEL_CATALOG_KIND, activeCodexModelsCachePath, applyCatalogMetadata, applyMultiAgentMode, applyNativeOpenAiContextOverride, applyRoutedCodexToolMode, catalogBackupPathFor, catalogHasRoutedEntries, catalogModelSlug, ensureStrictCatalogFields, findNativeTemplate, isDefaultCatalogPath, isRoutedModelCompatibilityExcluded, legacyCatalogBackupPath, normalizeRoutedCatalogEntry, normalizeServiceTiers, readCatalog, readCatalogBackup, readCodexCatalogPath, readConfiguredAutoReviewModel, readNativeBaseline } from "./parsing"; | ||
| import type { CatalogModel, MultiAgentMode, RawCatalog, RawEntry } from "./parsing"; | ||
| import { accountBoundNativeOpenAiSlugs, accountBoundNativeOpenAiSlugsBySelector, applyNativeVisibility, CODEX_NATIVE_ALIAS_CATALOG_KIND, desktopAllowlistSuppressedNativeSlugs, disabledNativeSlugs, isNativeAliasCatalogEntry, isUnsupportedOpenAiNativeSlug, NATIVE_OPENAI_MODELS, nativeContextLimits, observedAccountBoundNativeEntries, shouldIncludeAccountBoundNativeOpenAi, shouldIncludeNativeOpenAi, shouldUpgradeToUpstreamEntry, SUPPORTED_NATIVE_OPENAI_SLUGS, upstreamNativeEntry, type NativeContextLimitsInput } from "./metadata"; | ||
| import { | ||
|
|
@@ -1403,6 +1403,30 @@ function catalogModelsForMergeWithNativeRecovery( | |
| ]); | ||
| } | ||
|
|
||
| const AUTO_REVIEW_MODEL_CONTROL_CHARS = /[\u0000-\u001f\u007f-\u009f\u2028\u2029\s]/; | ||
|
|
||
| export function isValidAutoReviewModel(value: unknown): value is string { | ||
| if (typeof value !== "string") return false; | ||
| const trimmed = value.trim(); | ||
| return Boolean(trimmed) | ||
| && trimmed.length <= 1024 | ||
| && !AUTO_REVIEW_MODEL_CONTROL_CHARS.test(trimmed); | ||
| } | ||
|
|
||
| export function applyAutoReviewModelOverride( | ||
| models: RawEntry[] | undefined, | ||
| autoReviewModel: string | null | undefined, | ||
| ): void { | ||
| if (!models || !Array.isArray(models) || !autoReviewModel) return; | ||
| const trimmed = autoReviewModel.trim(); | ||
| if (!trimmed || !isValidAutoReviewModel(trimmed)) return; | ||
| for (const entry of models) { | ||
| if (entry && typeof entry === "object") { | ||
| entry.auto_review_model_override = trimmed; | ||
| } | ||
| } | ||
| } | ||
|
Comment on lines
+1416
to
+1428
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win Reject an The helper accepts any nonblank string and writes it to every catalog entry. A typo or stale Build an exact set from the synchronized catalog entries, validate The PR objective explicitly requires clear errors for unresolved configured model values. 🧰 Tools🪛 ast-grep (0.45.1)[warning] Importing child_process exposes a command-execution surface; ensure any command/argument built from input is validated, and prefer execFile/spawn with an argument array over exec. (detect-child-process-typescript) 🤖 Prompt for AI Agents |
||
|
|
||
| function writeRetainedCatalogSync({ | ||
| config, | ||
| goModels, | ||
|
|
@@ -1596,6 +1620,10 @@ function writeRetainedCatalogSync({ | |
| }, | ||
| }); | ||
| clampCatalogModelsToCodexSupport(catalog.models); | ||
| const autoReviewModel = readConfiguredAutoReviewModel(); | ||
| if (autoReviewModel) { | ||
| applyAutoReviewModelOverride(catalog.models, autoReviewModel); | ||
| } | ||
|
Comment on lines
+1623
to
+1626
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🗄️ Data Integrity & Integration | 🟠 Major | 🏗️ Heavy lift Centralize auto-review override application at the shared catalog finalization boundary. The current implementation duplicates configuration reading and stamping across catalog writers. Move the operation to one shared post-merge, pre-serialization finalizer so both paths use identical validation and precedence.
🧰 Tools🪛 ast-grep (0.45.1)[warning] Importing child_process exposes a command-execution surface; ensure any command/argument built from input is validated, and prefer execFile/spawn with an argument array over exec. (detect-child-process-typescript) 📍 Affects 2 files
🤖 Prompt for AI Agents |
||
|
|
||
| const added = goEntries.length + accountBoundEntries.length; | ||
| const content = `${JSON.stringify(catalog, null, 2)}\n`; | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.