# drift-audit Classify a browser-automation repo's selector maintenance history, straight from git. Answers one question: **how much of the selector churn in this repo is actually portal drift, and what shape does that drift take?** Read-only. No network, no credentials, no model, no dependencies. It runs one `git log` against a local checkout and classifies what comes back. ## Run it ```bash node drift-audit.mjs /path/to/your/checkout --since 2025-08-28 ``` Writes `report/report.md` and `report/classified.csv`. Takes a few seconds. ``` --since YYYY-MM-DD window start (default: one year ago) --pathspec GLOB which files count as selector definitions (default: *elector*) --out DIR output directory (default: ./report) ``` ## What it does 1. **Splits commits by diff shape.** A commit that only *adds* selectors is a new payer, a new field, or a new auth flow. That is product work. Only commits that *modify* an existing selector are drift repair. In practice this is the difference between a headline number and a defensible one. 2. **Recovers `(old, new)` selector pairs** from the diff, matched on the enum key so an unrelated addition in the same hunk is not mistaken for a change. 3. **Names the shape of each change** — see below. 4. **Estimates repair posture**, clearly labelled as an estimate. Reverts are detected and excluded so a change and its undo are not both counted. ## Shapes | shape | meaning | |---|---| | `RENAME` | tokens changed, structure intact | | `ANCESTOR_ADDED` | a wrapper appeared above the target | | `DESCENDANT_ADDED` | the target moved one level in | | `PATH_SHORTENED` / `PATH_DEEPENED` | intermediate steps dropped or inserted | | `ATTR_OPERATOR` | same attribute, different match operator (`=` to `*=`) | | `ANCHOR_SWITCH` | same element, anchored on a different attribute | | `DISAMBIGUATE` | old selector still matched, but too much | | `FALLBACK_ADDED` | original kept, an alternative added alongside | | `WIDGET_SWAP` | the component itself was replaced | | `RESTRUCTURE` | multiple steps changed, low token overlap | | `UNPAIRED` | selector changed, no `(old, new)` pair recoverable | ## What it does not tell you Whether a repair loop would actually have fixed any of these. That needs the DOM before and after, which is not in git. The posture column infers from the shape of the change alone and is an upper bound. The report says so in its own words. Two more limits it states rather than hides: selector files are a floor (drift also lands in extraction and navigation helpers), and commits are not incidents. ## Tests ```bash node test.mjs ``` 13 golden cases, every selector pair taken from a real production commit. Three of them are regression tests for bugs this tool shipped with: - whitespace inside a quoted attribute value is not a descendant combinator - steps removed from the middle of a path are neither a prefix nor a suffix match - one auth selector in a commit does not make every selector in it auth work