Commit e9d0f83
authored
Minimize imports via lake shake and add import lint/stats (#1020)
## Summary
Run `lake shake` to minimize the import graph across all 293 Strata
modules,
reducing average transitive Strata imports by 32% (56 → 38) and total
transitive
imports (including Lean/Std) by 40% (1379 → 831). Add CI linting to
ensure
`Strata.lean` transitively imports every module, and add an import
statistics
script for ongoing measurement.
## Changes
- **Import lint driver (`Scripts/CheckImports.lean`)**: Verifies that
all `.lean`
files under `Strata/` are transitively imported by `Strata.lean`.
Registered as
`lintDriver` in `lakefile.toml` so `lake lint` runs it automatically.
Supports
`-- noimport: Strata.Foo` comments in `Strata.lean` to allowlist
intentionally
excluded modules.
- **Import statistics script (`Scripts/ImportStats.lean`)**: Computes
per-module
transitive import counts (both total and Strata-only), reporting
average,
median, min, max, top/bottom lists, and histograms. Run via `lake exe
ImportStats`.
- **`lake shake Strata --fix`**: Applied shake's suggestions to remove
unnecessary
imports across 225 files (net -185 lines). This is the bulk of the
change.
- **Aggregator modules use `-- shake: keep`**: Pure aggregator modules
(`CBMC.lean`, `GOTO.lean`, `B3.lean`, `Dyn.lean`, `Python.lean`,
`Imperative.lean`, `Lambda.lean`, `DDM.lean`, `LExprType.lean`,
`B3/Verifier.lean`) intentionally re-export their submodules and are
annotated
with `-- shake: keep` so `lake shake --fix` won't strip them.
- **DDM elaboration imports use `-- shake: keep`**: Files using
`#dialect`,
`#strata`, `#strata_gen`, and related macros have elaboration-time
import
dependencies that shake cannot detect. These are annotated with
`-- shake: keep` to prevent breakage.
- **Renamed aggregator files**: `Dyn/Dyn.lean` → `Dyn.lean`,
`Python/Python.lean` → `Python.lean`, `Imperative/Imperative.lean` →
`Imperative.lean` — the `Foo/Foo.lean` pattern is unnecessary now that
these
are proper `module` files.
- **Orphaned modules added to `Strata.lean`**: When shake stripped
re-exports
from real code files (e.g. `ProgramWF.lean` no longer re-exports
`StatementWF`),
the orphaned modules were added directly to `Strata.lean` to maintain
full
coverage.
## Results
| Metric | Before | After | Change |
|---|---|---|---|
| Avg transitive imports (Strata-only) | 56.2 | 38.2 | -32% |
| Median transitive imports (Strata-only) | 38 | 22 | -42% |
| Avg transitive imports (all) | 1379 | 831 | -40% |
| Total import edges (Strata-only) | 16,455 | 11,194 | -32% |
| Clean build time | 3m 02s | 2m 58s | -2% |
By submitting this pull request, I confirm that you can use, modify,
copy, and
redistribute this contribution, under the terms of your choice.1 parent beb9b9c commit e9d0f83
221 files changed
Lines changed: 408 additions & 855 deletions
File tree
- StrataTest
- Backends/CBMC
- GOTO
- SimpleAdd
- DL
- Imperative
- Lambda
- Languages
- B3
- Verifier
- C_Simp/Examples
- Core
- Examples
- Tests
- Laurel
- Python
- Transform
- Strata
- Backends/CBMC
- GOTO
- DDM
- Elab
- Util/Ion
- DL
- Imperative
- Lambda
- Denote
- SMT
- DDMTransform
- Util
- Languages
- B3
- DDMTransform
- Verifier
- Boole
- C_Simp
- DDMTransform
- Core
- DDMTransform
- Dyn
- DDMTransform
- Laurel
- Grammar
- Python
- Regex
- Specs
- Pipeline
- Transform
- Util
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
15 | | - | |
| 15 | + | |
16 | 16 | | |
17 | | - | |
| 17 | + | |
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
| |||
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
| 28 | + | |
| 29 | + | |
28 | 30 | | |
29 | 31 | | |
30 | 32 | | |
| |||
71 | 73 | | |
72 | 74 | | |
73 | 75 | | |
74 | | - | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
11 | | - | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
9 | | - | |
10 | | - | |
11 | | - | |
12 | 9 | | |
| 10 | + | |
13 | 11 | | |
14 | 12 | | |
15 | 13 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
8 | | - | |
9 | 8 | | |
| 9 | + | |
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
11 | | - | |
12 | | - | |
13 | | - | |
14 | | - | |
15 | | - | |
| 11 | + | |
| 12 | + | |
16 | 13 | | |
17 | | - | |
18 | | - | |
19 | | - | |
20 | 14 | | |
21 | 15 | | |
22 | 16 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
9 | | - | |
10 | 9 | | |
11 | 10 | | |
12 | 11 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
8 | | - | |
9 | | - | |
10 | 8 | | |
11 | 9 | | |
12 | | - | |
13 | | - | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
14 | 16 | | |
15 | 17 | | |
16 | 18 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
8 | | - | |
9 | 8 | | |
10 | 9 | | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
11 | 15 | | |
12 | 16 | | |
13 | 17 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
9 | | - | |
10 | 9 | | |
11 | 10 | | |
12 | 11 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
8 | | - | |
9 | | - | |
10 | 8 | | |
11 | 9 | | |
12 | 10 | | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
13 | 14 | | |
14 | 15 | | |
15 | 16 | | |
| |||
0 commit comments