DIT-13464: Capture the raw literal (snapshot_text) in source-code extractors - #6
Merged
laurakoye merged 2 commits intoAug 18, 2026
Merged
Conversation
jholiga
approved these changes
Aug 18, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview
Adds
snapshot_textto scan candidates: the raw source span a value came from, quotes and escapes intact.value_rawis decoded —"Line one\nLine two"arrives holding a real newline — so it can't be searched for in the file, and writing it back would mangle the syntax around it.snapshot_textis a verbatim slice, sosource.includes(snapshot_text)always holds.snapshotText?: stringonExtractedHit, emitted assnapshot_text: string | nullon the candidate.javascript,html-markup(three push sites),vue(inherits),kotlin,swift,fallback.valueNode?.text()that could never yieldundefined— both branches of the loop above set the node and the text together. Stating that as one guard is what lets DIT-13480: Capture the raw literal (snapshot_text) in resource-file extractors #4's type flip compile.Nothing server-side is needed to merge — zod strips unknown keys, so the field is ignored on arrival for now.
Context
DIT-13464, part of DIT-13405.
Re-lands #3, which merged to the wrong base. #3's base was still
laura/dit-13463-stable-occurrence-index, and #2 merged that branch tomain85 seconds earlier — so #3 merged into a spent branch and none of it reachedmain. This is8478306andcd24c3acherry-picked straight ontomain, unchanged. Cherry-picked rather than merging the old branch, which would have draggedversionback to 0.2.0 andengines.nodeback to >=22, reverting #5.A code link identifies a string by (file, value, occurrence index) and stores
snapshot_textas the code's own rendering of it. Schema design.Screenshots
None — extraction output only.
Test Plan
1. The suite
A
describe.eachtable asserts, per extractor, thatsnapshotTextis a string on every hit and thatsource.includes(hit.snapshotText)holds. Four further cases pin what the snapshot keeps and the value drops: escapes, quote style, a template literal's${...}, and inline markup in a JSX text run.2. Coverage on a real app
The suite runs on hand-written snippets. This checks a real codebase, and that the nulls land only where they should.
snap.mjsgoes in the repo root —./dist/index.jsresolves relative to the script, not the working directory.3. What to look for
Every null is a
resource_value. Expected: this PR only touches the source-code extractors, so resource files stay null until DIT-13480. Any other kind appearing in that list means an extractor emitted a value it can't point at in the source.Note:
yarn linking this into the CLI and runningyarn scandoes not exercise this code until cli#151 merges — the CLI still uses its own copy.