Skip to content

refactor: split the drift check into rule classes run by a validator - #109

Merged
emaarco merged 1 commit into
mainfrom
emaarco/drift-checks-transparency-audit
Nov 5, 2026
Merged

emaarco merged 1 commit into
mainfrom
emaarco/drift-checks-transparency-audit

Conversation

@emaarco

@emaarco emaarco commented Nov 5, 2026

Copy link
Copy Markdown
Member

Why

The drift check lived in one script where several unnamed checks were bundled into a few large functions, so a failure did not say which rule raised it and single rules were hard to test or extend.

What

  • Each check of npm run drift is now a class extending DriftRule under scripts/drift/rules/ (12 rules: lock, classification, manifest hygiene, variant parity).
  • DriftValidator knows all rules and runs them against a DriftContext, which computes the snapshot, the lock comparison and the Kotlin/Java variant pairs once.
  • Supporting classes: DriftSnapshot, VariantPair, EngineNormalizer, ManifestScope.
  • Every message is prefixed with its rule's name, e.g. [LockedCopiesStayIdentical] LICENSE drifted in …; the message text itself is unchanged.
  • scripts/check-drift.mjs stays the CLI entry point, so npm run drift, npm run drift:update and the pre-commit hook are unchanged.
  • Tests added for the five rules that had none.

Verification

  • npm test: 48 of 48 pass; the existing assertions only gained the rule prefix.
  • npm run drift: 12 examples in step, 4473 locked copies.
  • npm run drift:update regenerates an identical drift.lock.yml.
  • Appending a line to one example's LICENSE reports the drift as before.

Each check of npm run drift is now a DriftRule subclass under scripts/drift/rules/.
DriftValidator runs all rules against a DriftContext that computes the snapshot,
lock comparison and variant pairs once. Every message is prefixed with its rule's
name. check-drift.mjs stays the CLI entry point.
@emaarco
emaarco enabled auto-merge (squash) November 5, 2026 14:08
@emaarco
emaarco merged commit 0605f71 into main Nov 5, 2026
45 checks passed
@emaarco
emaarco deleted the emaarco/drift-checks-transparency-audit branch November 5, 2026 14:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant