Commit 7904d88
committed
fix(fingerprint): address review findings on corpus mode
Four issues raised by CodeRabbit on #70, three of them real defects:
1. O(n^2) building the shape -> groups map. `Vec::contains` was a linear
membership scan repeated per indexed entry, and it degraded exactly on
the path this feature exists for — one shape carried by many groups.
CLAUDE.md forbids O(n^2) algorithms outright. Now a BTreeSet, which also
removes the separate sort since it iterates in order. Verified to produce
byte-identical output to the previous implementation on a 955-document
corpus, so this is purely a complexity fix.
2. An unreadable subdirectory aborted the whole scan. `read_dir(...)?`
propagated out of collect_corpus_files, so one permission-denied
directory failed the entire command after thousands of files had already
been walked — inconsistent with the per-file error model build_index
already used. Directory and entry failures are now collected into the
same `errors` list as parse failures, and the walk continues.
3. Entry-level failures were silently dropped. `let Ok(entry) = ... else
continue` discarded unreadable entries with no counter and no
diagnostic, so files_scanned could undercount without saying so. Each
now produces an error entry.
4. No coverage for --format text in corpus mode, and the text output
labelled cluster size as "document(s)" when `size` counts groups. The
label directly contradicted the design rationale — a cluster of 3
packages can span dozens of files. Corrected to "group(s)" and pinned by
a test that also asserts the old wording is absent.
collect_corpus_files now returns a `Walk` struct rather than a tuple, since
it carries three things.
Tests: +2 integration tests (text output reports counts and labels groups;
an unreadable directory is reported and non-fatal, unix-gated).1 parent ac4e432 commit 7904d88
3 files changed
Lines changed: 179 additions & 42 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
16 | | - | |
| 16 | + | |
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
| |||
120 | 120 | | |
121 | 121 | | |
122 | 122 | | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
123 | 134 | | |
124 | 135 | | |
125 | 136 | | |
126 | 137 | | |
127 | 138 | | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
128 | 144 | | |
129 | 145 | | |
130 | | - | |
131 | | - | |
132 | | - | |
133 | | - | |
134 | | - | |
| 146 | + | |
| 147 | + | |
135 | 148 | | |
136 | 149 | | |
137 | 150 | | |
138 | | - | |
139 | | - | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
140 | 156 | | |
141 | 157 | | |
142 | 158 | | |
143 | | - | |
144 | | - | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
145 | 169 | | |
146 | 170 | | |
147 | | - | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
148 | 181 | | |
149 | 182 | | |
150 | | - | |
151 | | - | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
152 | 192 | | |
153 | 193 | | |
154 | 194 | | |
155 | 195 | | |
156 | 196 | | |
157 | 197 | | |
158 | 198 | | |
159 | | - | |
| 199 | + | |
160 | 200 | | |
161 | | - | |
| 201 | + | |
162 | 202 | | |
163 | 203 | | |
164 | 204 | | |
| |||
168 | 208 | | |
169 | 209 | | |
170 | 210 | | |
171 | | - | |
172 | | - | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
173 | 214 | | |
174 | 215 | | |
175 | 216 | | |
| |||
181 | 222 | | |
182 | 223 | | |
183 | 224 | | |
184 | | - | |
185 | | - | |
| 225 | + | |
186 | 226 | | |
187 | 227 | | |
188 | 228 | | |
189 | 229 | | |
190 | 230 | | |
| 231 | + | |
191 | 232 | | |
192 | 233 | | |
193 | 234 | | |
| |||
211 | 252 | | |
212 | 253 | | |
213 | 254 | | |
214 | | - | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
215 | 265 | | |
216 | 266 | | |
217 | 267 | | |
| |||
253 | 303 | | |
254 | 304 | | |
255 | 305 | | |
256 | | - | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
257 | 311 | | |
258 | | - | |
259 | | - | |
260 | | - | |
261 | | - | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
262 | 316 | | |
263 | 317 | | |
264 | 318 | | |
265 | 319 | | |
266 | 320 | | |
267 | 321 | | |
268 | | - | |
269 | | - | |
270 | | - | |
| 322 | + | |
| 323 | + | |
271 | 324 | | |
272 | 325 | | |
273 | 326 | | |
| |||
280 | 333 | | |
281 | 334 | | |
282 | 335 | | |
283 | | - | |
| 336 | + | |
284 | 337 | | |
285 | 338 | | |
286 | | - | |
| 339 | + | |
287 | 340 | | |
288 | 341 | | |
289 | 342 | | |
| |||
473 | 526 | | |
474 | 527 | | |
475 | 528 | | |
476 | | - | |
477 | | - | |
478 | | - | |
479 | | - | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
480 | 534 | | |
481 | 535 | | |
482 | 536 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1651 | 1651 | | |
1652 | 1652 | | |
1653 | 1653 | | |
1654 | | - | |
| 1654 | + | |
1655 | 1655 | | |
1656 | | - | |
| 1656 | + | |
1657 | 1657 | | |
1658 | | - | |
1659 | | - | |
| 1658 | + | |
| 1659 | + | |
| 1660 | + | |
1660 | 1661 | | |
1661 | 1662 | | |
1662 | 1663 | | |
1663 | 1664 | | |
1664 | | - | |
| 1665 | + | |
| 1666 | + | |
| 1667 | + | |
| 1668 | + | |
| 1669 | + | |
1665 | 1670 | | |
1666 | 1671 | | |
1667 | 1672 | | |
1668 | 1673 | | |
1669 | | - | |
1670 | | - | |
| 1674 | + | |
1671 | 1675 | | |
1672 | 1676 | | |
1673 | 1677 | | |
| |||
1721 | 1725 | | |
1722 | 1726 | | |
1723 | 1727 | | |
1724 | | - | |
| 1728 | + | |
1725 | 1729 | | |
1726 | 1730 | | |
1727 | 1731 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
296 | 296 | | |
297 | 297 | | |
298 | 298 | | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
299 | 378 | | |
300 | 379 | | |
301 | 380 | | |
| |||
0 commit comments