Skip to content

Commit d01115e

Browse files
CI + CLAUDE.md: shake unused-import baseline gate
Adds a `lake exe shake OpenGALib --no-downstream` step in CI that counts flagged files and fails the build on growth. Baseline `35` captures the current import-hygiene debt remaining after the two recent shake-pass commits (60 → 45 → 35). Discipline mirrors `EXPECTED_SORRY` and the three linter baselines: the count only ever decreases. To shrink, apply shake's suggestion to the flagged file, add explicit imports to any broken downstream consumers (Mathlib-standard "every file declares its actual dependencies"), then drop the EXPECTED_SHAKE value. CLAUDE.md grows a "Unused-import hygiene" section documenting the tool, the noshake.json baseline, and the known `--fix` quirk (over-applies on our codebase, so manual / scripted apply with full-build verification is the supported workflow).
1 parent 790d38e commit d01115e

2 files changed

Lines changed: 23 additions & 0 deletions

File tree

.claude/CLAUDE.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,14 @@ CI implementation (`.github/workflows/ci.yml`): the build job greps `lake build`
166166

167167
Adding a new linter: drop `OpenGALib/Util/Linter/<Name>.lean` (template: `MathTag.lean`), add the option to the `register_linter_set` in `Util/Linter.lean`, add a `#guard_msgs` test in `Tests/Linter/<Name>.lean`, add the baseline check in `ci.yml`. The `Util/Linter/README.md` walks the full template.
168168

169+
## Unused-import hygiene (`shake`)
170+
171+
`lake exe shake OpenGALib --no-downstream` (from the `batteries` package) detects unused imports and missing transitive-relied-on imports. False positives (tactic / notation / instance side-effect modules) are filtered via `scripts/noshake.json` — Mathlib's universal `ignoreImport` baseline plus OpenGALib-specific side-effect modules.
172+
173+
CI baselines the count (currently `35`); growth fails the build. Cleanup is gradual: each PR either holds the count or reduces it. To reduce, apply shake's suggestion (`remove [old]`, `add [new]`) to the flagged file; if the full build then breaks downstream, add the right explicit imports to the broken consumer file (the Mathlib-standard "make every file declare its actual dependencies" pattern) and re-verify.
174+
175+
Shake's `--fix` flag is known to over-apply (removes more than reported) on our codebase, so manual / scripted apply with full-build verification is the supported workflow.
176+
169177
## Sorry discipline
170178

171179
Every sorry / opaque / placeholder is categorized:

.github/workflows/ci.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,3 +124,18 @@ jobs:
124124
FAIL=1
125125
fi
126126
exit $FAIL
127+
128+
- name: Shake — unused-import baseline
129+
run: |
130+
# `lake exe shake` flags files with unused imports (and missing
131+
# transitive-relied-on imports). Baseline is current debt; CI
132+
# fails on growth, mirrors Mathlib's `noshake.json` discipline.
133+
ACTUAL=$(lake exe shake OpenGALib --no-downstream 2>&1 | grep -c "^/.*\.lean:$" || echo 0)
134+
EXPECTED_SHAKE=35
135+
echo "Shake suggestions: $ACTUAL (expected ≤ $EXPECTED_SHAKE; gradually reduce)"
136+
if [ "$ACTUAL" -gt "$EXPECTED_SHAKE" ]; then
137+
echo "::error::Shake regression: $ACTUAL > $EXPECTED_SHAKE"
138+
echo "Add the missing import to the consumer file, or update EXPECTED_SHAKE only when reducing."
139+
echo "Run \`lake exe shake OpenGALib --no-downstream\` locally to see the suggestions."
140+
exit 1
141+
fi

0 commit comments

Comments
 (0)