codex-security icon indicating copy to clipboard operation
codex-security copied to clipboard

Avoid repeatedly materializing quadratic scan-history matching payloads

Open GautamSharma99 opened this issue 4 months ago • 3 comments

Summary

The workbench matching plan repeats findings from earlier scans in each later batch. Across a long history, constructing and serializing that plan can grow approximately quadratically, even before the model-side matching work is considered.

Current status

#575 added compact model catalogues and #782 added paged/batched matching work. The old subprocess stdout limit was also removed. The original claims that every comparison uses one unbounded model prompt and necessarily hits a 4 MiB stdout cap no longer describe current behavior.

The remaining workbench batch construction still materializes earlier findings into each later batch. Model prompt improvements do not remove that response-level duplication.

Example

For successive scans A, B, C, and D, a plan that embeds full earlier findings produces:

B: before = [A]
C: before = [A, B]
D: before = [A, B, C]

The same A/B payload is copied and serialized repeatedly. A single finding-heavy scan can therefore enlarge many later batches.

Expected behavior

  • Avoid repeated materialization/serialization while preserving all required comparisons and semantic grouping.
  • Consider shared references, incremental retrieval, or existing batching facilities rather than introducing an arbitrary history ceiling.
  • Preserve resumability and equivalent matching results across batches.
  • Use a synthetic large-history regression to measure the relevant workbench payload/memory behavior separately from model context size.

#149 remains open but predates some of the shipped matching changes. Its scope should be reassessed against the remaining duplication instead of restoring obsolete limits.

GautamSharma99 avatar Jul 30 '26 12:07 GautamSharma99

Two open branches overlap here: #149 is the focused contributor implementation for bounded scan-history payloads, while #153 folds that work into a larger, currently conflicted aggregate that also includes #120, #121, #122, and #155. Prefer #149 as the implementation for this issue; keep matching isolation, renderer resilience, cosmetic alignment, and report severity behavior separate unless a specific integration regression requires coordination.

mldangelo-oai avatar Aug 03 '26 03:08 mldangelo-oai

#153 reduced repeated database reads, and #330 removed the old subprocess-output ceiling. The remaining issue is quadratic history duplication and model-context growth; any fix should avoid arbitrary local size limits.

mldangelo-oai avatar Aug 15 '26 07:08 mldangelo-oai

Merged #575 adds compact catalogues and paged evidence; #782 restores automatic matching batches. Those help with model inputs, but the workbench still repeats earlier findings across the full history response.

mldangelo-oai avatar Oct 08 '26 00:10 mldangelo-oai