Detector architecture v2: static engine, benchmarks, lab, and visual contrast#156
Detector architecture v2: static engine, benchmarks, lab, and visual contrast#156pbakaus wants to merge 20 commits into
Conversation
Deploying impeccable with
|
| Latest commit: |
72d7e57
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://0a7319f9.impeccable-2rv.pages.dev |
| Branch Preview URL: | https://codex-detector-v2-speed-visu.impeccable-2rv.pages.dev |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit d9b7070. Configure here.
| styleEl.remove(); | ||
| if (spotlightBackdrop) { spotlightBackdrop.remove(); spotlightBackdrop = null; } | ||
| document.body.classList.remove('impeccable-hidden'); | ||
| } |
There was a problem hiding this comment.
Remove handler misses lazy visual contrast observer cleanup
Medium Severity
The 'remove' action handler manually cleans up overlays but doesn't call disconnectLazyVisualContrastObserver() or increment scanGeneration. The clearOverlays() function does both, but the remove handler reimplements cleanup without these. If the lazy visual contrast IntersectionObserver is active, its pending resolutions can still fire, pass the staleness check (generation !== scanGeneration remains equal), call highlight() to append new overlays, and send stale findings to the extension panel — all after the user has explicitly removed everything.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit d9b7070. Configure here.


Summary
This PR turns the detector work into a much more explicit architecture, with the speed and inspection tooling needed to keep improving it safely.
Detector architecture
cli/engine/detect-antipatterns.mjswhile moving implementation intocli/engine/engines/*,cli/engine/rules/*,cli/engine/shared/*, andcli/engine/browser/injected/*.Static HTML/CSS engine
htmlparser2,css-select,css-tree, anddomutils.@layerflattening, selector matching, specificity/source order,!important, inline styles, variables/fallbacks, inherited typography properties, and needed shorthand expansion.Browser, visual contrast, and extension behavior
createBrowserDetector()for warm browser reuse while keeping one-shotdetectUrl()compatibility.window.impeccableDetect()/window.impeccableDetectAsync()andwindow.impeccableScan()/window.impeccableScanAsync().Benchmarks and detector lab
scripts/benchmark-detector.mjsplusbench:detectorandbench:detector:browserscripts./detectorworkbench for navigating antipattern fixtures, running scans in an iframe, viewing findings, and seeing timing at a glance.Validation
bun run testbun run build:browserbun run build:extensionbun run build:skillsbun run build:sitebun run bench:detector -- --quickbun run bench:detector:browser -- --quickgit diff --checkNotes
Note
Medium Risk
Medium risk because it introduces a new CLI entry path and substantially expands the in-browser detector runtime (overlay lifecycle + optional visual contrast sampling), which can affect scan accuracy/performance and extension messaging behavior.
Overview
Refactors the detector’s entrypoints and browser runtime toward a modular architecture. Adds a new CLI implementation (
cli/engine/cli/main.mjs) that supports scanning stdin/files/dirs/URLs, optional--fastregex-only mode, JSON output, dev-server detection hints, large-scan confirmation, and import-graph annotations in output.Overhauls the browser/extension injected detector runtime. Introduces
cli/engine/browser/injected/index.mjsand updates the generateddetect-antipatterns-browser.jsto build from it, adding async scan/detect APIs (impeccableDetect*,impeccableScan*), overlay lifecycle cleanup, extension-safe error posting, configurable auto-scan, and an optional visual contrast pass that samples rendered backgrounds (incl. images/gradients) with lazy offscreen resolution.Dependency changes: removes
jsdomand adds a static parsing stack (htmlparser2,css-select,css-tree,domutils) reflected inbun.lock, alongside minor version shifts (e.g.,entities,parse5,undici).Reviewed by Cursor Bugbot for commit 72d7e57. Bugbot is set up for automated code reviews on this repo. Configure here.