fix: limit finding comparison input size - #638
Conversation
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
mldangelo-oai
left a comment
There was a problem hiding this comment.
Reviewed current head 596a73a. The batching and group-merging checks pass, but the shared matcher now starts uncapped post-completion model calls for cost-limited ordinary scans; see the inline comment.
| const outputSchema = z.toJSONSchema(comparisonSchema, { | ||
| target: "openapi-3.0", | ||
| }); | ||
| for (const batch of comparisonBatches(input)) { |
There was a problem hiding this comment.
[P1] Keep batched post-scan matching inside the requested cost bound
matchScanFindingsInternal is also used by ordinary CodexSecurity.run() history matching, not just component scans. That path calls matchCompletedScan only after tracker.stop(...) and complete-scan have already persisted the final cost, and it does not pass maxCostUsd or any remaining budget into this loop. With four synthetic 300 KB historical findings and one 5 KB new finding, I reproduced four additional model turns after completion; the README currently allows only one extra call when a cost limit is set. Larger histories can therefore generate many untracked, uncapped turns despite --max-cost, without appearing in the recorded scan cost. Please either keep batching specific to explicitly unbounded component matching or propagate and enforce the remaining scan budget before starting subsequent batches, and update the single-call documentation accordingly.
Summary
Large finding comparisons can exceed the Codex input limit and leave matching incomplete. Each comparison included all earlier findings in one request. Split large comparisons into smaller requests so the total finding count does not determine the size of a single request.
Changes
Testing
pnpm run test --seed 12345 --timeout 90000pnpm run test --timeout 90000pnpm run types,pnpm run format, andpnpm run buildpassed.Risk and rollout
No CLI options, result formats, or dependencies change. Large comparisons make more model requests. Small comparisons still use one request. Component retry behavior is unchanged. This change does not address process shutdown after a completed summary.
Public disclosure review