ghl-drift-check
Wraps script/drift_check.rb. The working tree is always restored to its pre-run state, regardless of whether drift is found — safe to run repeatedly.
Modes
| Invocation | Question answered |
|---|---|
ruby script/drift_check.rb |
"Does committed code match what the generator would emit against the currently-pinned OpenAPI SHA?" Catches forgotten regenerations after template or pin edits. Fast, no network. |
ruby script/drift_check.rb --upstream |
"Does committed code match what the generator would emit against upstream HEAD?" Catches API changes we haven't bumped to yet. Used by the weekly CI cron. Needs network. |
When to run
- Local mode: after editing
script/generate.rb, after runningbin/sync-specto bump the pin, or before opening a PR that touches generated code. Also runnable as a sanity check any time. - Upstream mode: the GitHub Actions cron runs this weekly. Locally only when you want to know "do I need to bump the pin?"
Exit codes
0— no drift.1— drift detected. The output lists the differing files. To resolve:- Local mode: run
bin/generateand commit the diff. - Upstream mode: bump
PIN_SHAinscript/fetch_specs.rb, runbin/sync-spec && bin/generate, commit the regenerated diff.
- Local mode: run
How it works
- Snapshots
lib/high_level/resources/,lib/high_level/models/, andlib/high_level/resource_registry.rbto a tmp dir. - (Upstream mode only) Temporarily checks out
vendor/openapi/at upstream HEAD; restored on exit. - Runs
bin/generate. - Diffs the snapshot against the freshly-generated tree.
- Restores the snapshot so the working tree is byte-identical to its pre-run state.
If you had uncommitted local changes in the watched paths, the script preserves them — the snapshot is taken before the generator runs and restored after.
Failure modes
- "vendor/openapi/ is not populated" — run
bin/sync-specfirst. - Drift in upstream mode — usually intentional (upstream did release something new). Time to bump.
- Drift in local mode after editing the generator — expected; run
bin/generateto roll the templates' output forward.