Commit bb61e76
fix: place user overrides first in deconfliction + add comprehensive tests
Fix a bug where a hash-based run sorting before a user-overridden run
would not be deconflicted against the user's explicit color choice.
The algorithm now has three phases:
- Phase 0: Place ALL user-overridden colors as immovable landmarks first,
regardless of sort position. This ensures every hash-based run is
always checked against every user-chosen color.
- Phase 1: Place cached non-user runs (preserving their deconflictions).
- Phase 2: Process remaining new non-user runs against the full set.
Add comprehensive test suite (oklch_colors_test.ts) covering:
- Basic: no runs, single run, distant colors (no deconfliction)
- Clash detection: identical colors, very similar colors, multiple clashes
- User overrides: never deconflicted, respected as landmarks, hash runs
checked against user colors regardless of sort order
- Mixed scenarios: user override in middle, user override sorting later
- Replacement quality: 3-axis search verified, sRGB-valid output
- Incremental/cache: cached runs preserved, new runs checked against all
- Determinism: same inputs → same outputs, Map insertion order independent
- Dark mode: different lightness ranges
- Stress: 30 identical runs, realistic 12-run scenario
Co-authored-by: Samuel <samuel@knutsen.co>1 parent ed775f5 commit bb61e76
3 files changed
Lines changed: 639 additions & 17 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
110 | 110 | | |
111 | 111 | | |
112 | 112 | | |
| 113 | + | |
113 | 114 | | |
114 | 115 | | |
115 | 116 | | |
| |||
121 | 122 | | |
122 | 123 | | |
123 | 124 | | |
| 125 | + | |
124 | 126 | | |
125 | 127 | | |
126 | 128 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
332 | 332 | | |
333 | 333 | | |
334 | 334 | | |
| 335 | + | |
335 | 336 | | |
336 | | - | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
337 | 352 | | |
338 | | - | |
| 353 | + | |
339 | 354 | | |
340 | | - | |
341 | 355 | | |
342 | | - | |
| 356 | + | |
343 | 357 | | |
344 | 358 | | |
345 | 359 | | |
346 | 360 | | |
347 | | - | |
348 | | - | |
| 361 | + | |
| 362 | + | |
349 | 363 | | |
350 | 364 | | |
351 | | - | |
| 365 | + | |
352 | 366 | | |
353 | | - | |
| 367 | + | |
354 | 368 | | |
355 | 369 | | |
356 | 370 | | |
357 | 371 | | |
358 | | - | |
359 | | - | |
360 | | - | |
| 372 | + | |
| 373 | + | |
361 | 374 | | |
362 | 375 | | |
363 | 376 | | |
| |||
368 | 381 | | |
369 | 382 | | |
370 | 383 | | |
371 | | - | |
372 | | - | |
| 384 | + | |
373 | 385 | | |
374 | 386 | | |
375 | 387 | | |
376 | 388 | | |
377 | | - | |
378 | | - | |
| 389 | + | |
379 | 390 | | |
380 | | - | |
381 | | - | |
| 391 | + | |
382 | 392 | | |
383 | 393 | | |
384 | 394 | | |
| |||
0 commit comments