Deep Scan reducer accepts placeholder ("X") finding text, and the degraded aggregate persists across reductions
Summary
During a long Deep Scan of a large repository, the reducer (dedup) worker repeatedly failed identity-preservation validation. It then submitted an aggregate in which the descriptive fields of 107 of 118 findings were replaced with the literal string X.
The host accepted that submission and the coordinator marked the reducer succeeded. Every later reduction and resume built on the degraded aggregate, so the final findings kept their titles but showed X for summaries and descriptions.
Reducer validation enforces identity and provenance accounting but not content. A submission that keeps every identity while blanking the text passes every gate.
Environment
| Observed on | npm-v0.3.0 |
| Still present on | main @ 2b8a969 (after npm-v0.5.1) |
| Scan mode | cs scan --mode deep, large repository, long run (~118 aggregated findings) |
templates/deep-scan/dedup.md has not changed between npm-v0.3.0 and main.
Observed behavior
Sequence from the reducer worker's transcript:
- Submitted 61 consolidated findings. Rejected:
Deep reduction discarded or changed a previously accepted finding identity. - Submitted 118 findings with real text. Rejected: 56 prior identities did not match, including findings where
locations[0].endLinewas omitted. - Tried other strategies, including submitting only new findings. All rejected by the same identity check.
- Assembled replacement payloads with shell commands. Several large outputs were truncated.
- Built a transformation that replaced the descriptive fields of every previous finding with
X, checked that the placeholders were generated, then ended the attempt without a successful reduction, citing a tool-call size limit. - The internal retry continued the same conversation and told it to submit a valid result. It submitted 118 findings, 107 with
Xfields. Accepted. The dedup worker was markedsucceeded. - Later reductions and checkpoint restores carried the
Xtext forward into the final results.
Expected behavior
The host should reject an aggregate in which previously accepted findings lose their substantive content. If the reducer cannot produce a valid aggregate, the reduction should fail, then be retried or surfaced as an error. It should not succeed with degraded data.
Root cause
1. No content check on reducer output
validateRetainedFindingschecks only that the output is not empty and that every previousscanFindingIdentityis present.parseDeepReduction→validateFindingSemanticschecks only severity scoring, line ranges and evidence refs.titleandsummaryusenonEmptyText: one non-whitespace character.
"X" satisfies all three.
2. Original text is archived, not restored
reconcileDeepReduction calls preserveFindingDetails. When the new finding no longer contains the previous one, that function appends the previous body to provenance.previousFindings (L1761) and leaves the degraded top-level fields in place.
The next reducer's input view leaves out those retained bodies (dedup.md L42), so the next reducer sees and carries forward the X text.
3. Identity breaks easily
Without an explicit identity, scanFindingIdentity is [ruleId, path, startLine, endLine ?? null]. Dropping endLine when re-emitting a finding changes its identity, and the reducer must re-emit every previous finding on every pass.
4. Pressure that grows with scan size
Each reduction must resubmit the full aggregate in a single record_codex_security_deep_reduction call. The prompt says to retry "until it succeeds" (dedup.md L56), with no bound within a turn. At ~100+ findings, output and tool-call size limits make "keep the identities, drop the content" the cheapest submission that passes.
Proposed fixes
- [ ] Content-preservation gate. In
reconcileDeepReduction, reject the submission when a retained previous finding'stitle,summary,writeup,rootCauseorremediationcollapses to placeholder text (X,...,TBD, etc.) or shrinks sharply compared with its previous or source body. Name the affected source refs in the validation error. - [ ] Host-side carry-forward. Let the reducer submit only merges and new findings, and refer to unchanged previous findings by
sourceFindingIdsalone; the host copies their bodies verbatim. This removes the need to re-emit, and possibly corrupt, the whole aggregate each pass, and prevents identity drift such as a droppedendLine. - [ ] Restore instead of archive. When a retained finding's top-level text is degraded and a non-degraded body exists in
previousFindingsorsourceFindings, restore it, or at least flag the finding. - [ ] Actionable identity diagnostics. On an identity-preservation failure, list each missing identity tuple with its closest submitted match (e.g. "same ruleId/path/startLine; endLine missing") so the model can make a targeted fix instead of rewriting everything.
- [ ] Bound the record loop. Cap
record_codex_security_deep_reductionattempts per reducer turn and fail the reduction cleanly at the cap. - [ ] Pre-seal lint. Warn when finalized findings contain placeholder text.
Related: #1865 (Deep Scan reducer prompt requires code mode, but reducer workers do not enable code mode).
The missing code mode is a possible contributing cause of this issue.
- This issue occurred on
npm-v0.3.0. That release bundles Codex0.162.1. In Codex0.162.1,code_modeis off by default. - In
npm-v0.3.0,plugins/codex-security/mcp-app/templates/deep-scan/dedup.mdtells the reducer to use code mode withloadandstore. plugins/codex-security/mcp-app/src/deep-scan/executor.tsdoes not enablefeatures.code_modefor reducer workers.- The transcript in this issue shows shell commands and truncated outputs. It does not show code-mode cells. Thus, code mode was probably not available to this reducer.
Without code mode, the reducer must write the full aggregate in the arguments of one record_codex_security_deep_reduction call. In this issue, the reducer cited a tool-call size limit before it replaced the finding text with X.
With code mode, the reducer can make the submission object in JavaScript. Then it can call tools.mcp__cs_artifacts__record_codex_security_deep_reduction from the code-mode cell. The submission does not go through the model output. The current prompt does not tell the reducer to do this.
#1865 does not fix this issue. The host still accepts placeholder text when all identities are present. The fixes in this issue are still necessary. Both issues propose more detail in the identity error from validateRetainedFindings.
#1910 fixed the reducer’s ability to page through inputs without code mode. It didn’t change what the host accepts: main still checks the identities and can accept X in place of the description. #1912 adds the missing content check and lets the host copy unchanged finding bodies. That’s the fix to follow here.