Repository navigation
Fix defects found in review of the scripted commands - #2
Merged
Merged
Conversation
A review of the merged scripted commands turned up defects, one destructive: - render --out <dataset folder> overwrote the source images with downscaled, drawn-on copies. It is now refused (exit 64), however the folder is spelled. - annotate read stdin whenever it wasn't a terminal, so inside a 'while read' loop it swallowed the loop's input. stdin is now read only with --from -; naming an image with no boxes and no --negatives is a usage error instead of a silent no-op. - For up to 256 named images annotate checked existence only, so A.JPG created a second entry beside a.jpg and annotations.json was accepted as an image. Names must now match what a listing returns: an image extension, spelled as stored, not hidden, directly in the folder. - A negative width or height was silently flipped positive by CGRect. Refused. - A box under one pixel rounded to zero on disk and was re-added on every run, breaking idempotency. Refused. - --image-size (and an entry's width/height) was ignored when the image could not be read, writing unscaled numbers. Now a reported problem. - An image supplied with no boxes was cleared in replace mode without --negatives, so 'detect | annotate --mode replace' wiped labels wherever the detector found nothing. 'No boxes' is now a no-op in both modes unless --negatives is given; an image whose every box was refused is left alone. - A corrupt annotations file exited 64 with a usage banner. It is a dataset problem: exit 1, and validate reports it as invalid-annotations-file. Unparseable --from content is exit 1 as well. - With --image, a single box object is accepted, and a code fence on one line is stripped. - Records hold the 2-decimal values the file will hold, so replacing an image's boxes with the same boxes no longer reports a change. Each has a unit test, and the smoke test gained a check per command-level finding. Help text, the skill and docs/agents.md describe the new behaviour.
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.
Why
An independent review of #1 finished after it was merged and found real defects in the scripted commands. None has shipped:
mainis ahead of the last release (0.2.1). This fixes all of the confirmed ones.What was wrong, and what happens now
render --out <dataset folder>annotateand stdinwhile readloop it swallowed the loop's input--from -. An image with no boxes and no--negativesis a usage error rather than a silent no-opannotateA.JPGcreated a second entry besidea.jpg;annotations.jsonwas accepted as an imageaddwas not idempotent--image-sizeon an unreadable image--mode replacewith an empty box listdetect | annotate --mode replacewiped labels wherever the detector found nothing--negativesis givenannotations.jsonvalidatereportsinvalid-annotations-fileas JSON--image a.jpgwith one box objectwritten: trueand rewrote the fileOne behaviour change to be aware of
Clearing an image now takes
--mode replace --negatives;--mode replacealone with an empty list does nothing. I think that is the right default (a detector that finds nothing should never delete labels), but it is a deliberate change to what #1 did.What the review found sound
No regressions in the four rewritten format files (loader, writer, indent sniffing, directory listing), no concurrency problems in
concurrentMapor the duplicate check, and the coordinate-convention arithmetic produced the expected numbers in every combination tried.How it was checked
swift test: 175 tests, 0 failures (9 new, one per finding).scripts/smoke-scripted.shnow has a check per command-level finding, including thatrenderleaves the source image byte-identical and that awhile readloop runs every iteration.docs/agents.mdwas re-run against the rebuilt binary and saves the same coordinates as before.stats0.2 s,annotate0.1 s,validate0.5 s).Not addressed
stats,validateandrender. The reviewer confirmed the old code behaved the same way, so it is not a regression; it deserves its own fix.🤖 Generated with Claude Code