perf(catalog): cache manifest built-in model suppression resolver#74236
Conversation
Greptile SummaryThis PR refactors the built-in model suppression check in Confidence Score: 3/5Not safe to merge as-is — the new fast path silently drops provider alias normalization, meaning suppression rules will fail for any aliased provider ID. One P1 logic defect: the closure returned by
Prompt To Fix All With AIThis is a comment left during a code review.
Path: src/agents/model-suppression.ts
Line: 85-87
Comment:
**Provider alias normalization dropped in new hot path**
The returned closure calls `normalizeLowercaseStringOrEmpty(input.provider)` inside `createManifestBuiltInModelSuppressionResolver`, but the original `shouldSuppressBuiltInModel` path went through `resolveBuiltInModelSuppressionFromManifest` → `normalizeProviderId(params.provider ?? "")`. `normalizeProviderId` maps several aliases to canonical names (e.g., `"bedrock"` → `"amazon-bedrock"`, `"modelstudio"` → `"qwen"`, `"bytedance"` → `"volcengine"`, `"z.ai"` → `"zai"`). Without this step, `buildModelCatalogMergeKey` will build the wrong key for any alias provider, and suppression entries stored under the canonical name will silently fail to match — leaving those models unsuppressed in the catalog.
```ts
return (input) => {
return resolver({ ...input, provider: normalizeProviderId(input.provider ?? "") })?.suppress ?? false;
};
```
Or apply `normalizeProviderId` inside `createManifestBuiltInModelSuppressionResolver`.
How can I resolve this? If you propose a fix, please make it concise.
---
This is a comment left during a code review.
Path: src/plugins/manifest-model-suppression.ts
Line: 152-170
Comment:
**`resolveManifestBuiltInModelSuppression` now creates a fresh resolver on every call**
Before this PR, `resolveManifestBuiltInModelSuppression` called `listManifestModelCatalogSuppressions` directly (one filesystem scan per call). After the refactor it instantiates a `createManifestBuiltInModelSuppressionResolver` — which also calls `listManifestModelCatalogSuppressions` — and then immediately uses it once and discards it. The cost per call is identical to before; nothing is cached here. Any caller outside the new hot path (e.g., `buildSuppressedBuiltInModelError`, `shouldSuppressBuiltInModel`) still pays the full scan cost on each invocation. This is expected for single-item use, but worth documenting in a comment to prevent future confusion about which function actually caches.
How can I resolve this? If you propose a fix, please make it concise.Reviews (1): Last reviewed commit: "perf(catalog): cache manifest built-in m..." | Re-trigger Greptile |
There was a problem hiding this comment.
Pull request overview
This PR refactors manifest-based built-in model suppression into a cached, reusable resolver to avoid repeated plugin manifest registry loads and heavy filesystem scanning during model catalog construction.
Changes:
- Added
createManifestBuiltInModelSuppressionResolverto compute manifest suppressions once and return a pure in-memory lookup closure. - Added
createShouldSuppressBuiltInModeland updatedloadModelCatalogto use a single resolver instance per catalog load. - Updated runtime exports and test mocks to expose/use the new factory API.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
src/plugins/manifest-model-suppression.ts |
Introduces a factory that captures planned suppressions once and resolves suppressions via an in-memory closure. |
src/agents/model-suppression.ts |
Adds createShouldSuppressBuiltInModel factory that wraps the manifest resolver for repeated suppression checks. |
src/agents/model-suppression.runtime.ts |
Exposes the new factory function via the runtime shim. |
src/agents/model-catalog.ts |
Switches catalog building from per-entry suppression checks to a single cached resolver used across the loop. |
src/agents/model-catalog.test.ts |
Updates the runtime mock to include createShouldSuppressBuiltInModel. |
|
Codex review: needs maintainer review before merge. Keep this PR open. Current main still calls the single-item manifest suppression resolver for every model catalog entry, while this PR is an active source/test-only implementation candidate for building one reusable resolver per catalog load. The latest PR head also appears to address the earlier alias-normalization review concern, so the right next step is normal maintainer review and targeted validation, not cleanup closure. Maintainer follow-up before merge: Keep this PR open for normal maintainer review. The mergeable shape is the one this PR is aiming for: compute manifest suppressions once per Best possible solution: Keep this PR open for normal maintainer review. The mergeable shape is the one this PR is aiming for: compute manifest suppressions once per Acceptance criteria:
What I checked:
Likely related people:
Remaining risk / open question:
Codex review notes: model gpt-5.5, reasoning high; reviewed against 1c17fd5edf79. |
9b53cb7 to
f20773b
Compare
f20773b to
11a3996
Compare
…enclaw#74236) * perf(catalog): cache manifest built-in model suppression resolver * fix(catalog): address PR review comments for manifest suppression resolver * fix(catalog): preserve cached suppression semantics --------- Co-authored-by: Vincent Koc <[email protected]>
…enclaw#74236) * perf(catalog): cache manifest built-in model suppression resolver * fix(catalog): address PR review comments for manifest suppression resolver * fix(catalog): preserve cached suppression semantics --------- Co-authored-by: Vincent Koc <[email protected]>
…enclaw#74236) * perf(catalog): cache manifest built-in model suppression resolver * fix(catalog): address PR review comments for manifest suppression resolver * fix(catalog): preserve cached suppression semantics --------- Co-authored-by: Vincent Koc <[email protected]>
…enclaw#74236) * perf(catalog): cache manifest built-in model suppression resolver * fix(catalog): address PR review comments for manifest suppression resolver * fix(catalog): preserve cached suppression semantics --------- Co-authored-by: Vincent Koc <[email protected]>
…enclaw#74236) * perf(catalog): cache manifest built-in model suppression resolver * fix(catalog): address PR review comments for manifest suppression resolver * fix(catalog): preserve cached suppression semantics --------- Co-authored-by: Vincent Koc <[email protected]>
Summary
listManifestModelCatalogSuppressionsinto a cached resolver function (buildManifestBuiltInModelSuppressionResolver) to avoid repeatedly reloading the manifest registry and generating 800+ full filesystem scans/loads when building the model catalog.shouldSuppressBuiltInModelloop calls with the pure-memoryresolverfunction.model-suppression.runtime.tsand its interface to expose the new factory method.Test plan
src/agents/model-catalog.test.ts,src/agents/model-suppression.test.ts, etc. pass successfully.loadModelCatalogconfirms only a single initial execution ofcreateManifestBuiltInModelSuppressionResolverduring the whole iteration.