Files
Dustin DeckerandCursor Agent 648aca62d5 Thread original chunk data through engine pipeline (#4780)
* [secret-storage] Thread original chunk data through engine pipeline

Adds OriginalData/ChunkData fields to preserve pre-decode source data
through the scan pipeline:

1. Chunk.OriginalData: captures chunk.Data before iterativeDecode
2. engine.go: sets chunk.OriginalData = chunk.Data before decode
3. ResultWithMetadata.ChunkData: populated by CopyMetadata from
   OriginalData (falls back to Data when nil)

This enables downstream consumers (e.g. the dispatcher in thog) to
access the original source data for secret storage encryption.

* Update TestChunkSize for OriginalData field addition

Chunk struct grew from 80 to 104 bytes with the OriginalData []byte
slice header (24 bytes). Field placement is already optimal (adjacent
to Data []byte).

* fix: preserve OriginalData field in EscapedUnicode decoder

The EscapedUnicode decoder constructed a new sources.Chunk manually
copying fields but omitted OriginalData. This caused CopyMetadata to
fall back to the decoded Data instead of the original pre-decode content,
defeating the purpose of preserving original chunk data for secret
storage encryption.

* Address PR review feedback: use testify/assert, add nil-guard comment, remove stale alignment comment

---------

Co-authored-by: Cursor Agent <[email protected]>
2026-03-03 14:34:05 -05:00
..