You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
extract: refuse writes that would shrink an existing file unless --force #25
Split out of #21, which is limited to the three splice and alias failures.
#21 suggested that extract refuse to write when the result would be smaller than the existing target file, unless --force is passed. The reporter says this guard would have caught every failure in #21.
They don't cover this. Since #15, extract refuses ambiguous mappings before it writes anything: several blocks for one file without distinct region= values, broken markers in an existing target, unsafe paths. It never compares sizes, though. Two cases can still shrink a file with no check:
--force replacing an existing whole file with a shorter block, which is the case this issue asks about.
A region splice whose new body is shorter than the old one. This is normal when you edit code, so a guard here would need a threshold.
What's still to decide:
Does --force cover this already? It's an explicit opt-in, so a shrink guard might mean a second flag (--allow-shrink) or a ratio threshold.
A region= block splices into the existing file. A file with an import, a region and an export kept the import and the export, and only the region body changed.
Without --force, an existing whole file is never overwritten. A 40-line src/whole.ts was skipped with "exists and has block(s) without region=. Use --force to overwrite." and extract exited 2.
extract --force is the only way left to shrink a file: the same src/whole.ts went from 40 lines to 1, exit 0. That is what --force asks for, so a guard would only add a second flag for the same intent.
Activity
adrianbrowning commentedon Oct 5, 2026
Triage note after #24 and #15:
They don't cover this. Since #15,
extractrefuses ambiguous mappings before it writes anything: several blocks for one file without distinctregion=values, broken markers in an existing target, unsafe paths. It never compares sizes, though. Two cases can still shrink a file with no check:--forcereplacing an existing whole file with a shorter block, which is the case this issue asks about.What's still to decide:
--forcecover this already? It's an explicit opt-in, so a shrink guard might mean a second flag (--allow-shrink) or a ratio threshold.adrianbrowning commentedon Oct 8, 2026
Closing as out of scope. The reasoning is recorded in
.out-of-scope/extract-shrink-guard.md(added in #60).Checked on main (238c32e):
region=block splices into the existing file. A file with an import, a region and an export kept the import and the export, and only the region body changed.--force, an existing whole file is never overwritten. A 40-linesrc/whole.tswas skipped with "exists and has block(s) without region=. Use --force to overwrite." andextractexited 2.extract --forceis the only way left to shrink a file: the samesrc/whole.tswent from 40 lines to 1, exit 0. That is what--forceasks for, so a guard would only add a second flag for the same intent.mdcode extract --check --force(feat: extract --check and the check-sync GitHub Action (#28, 1/2) #57) previews it without writing:src/whole.ts differs from this block; extract would overwrite it.Splices that make a region shorter are ordinary edits, so a size threshold there would refuse normal changes.
docs(triage): record the extract shrink guard as out of scope (#25) (#60