Commit 054d54d
authored
feat(lint): unpinned-headline rule (Smoke-pin coverage) (#6)
## Summary
Implements the spec's `unpinned-headline` lint (`docs/arghda-spec.adoc`
§Linter rules) — the last remaining v0 Agda lint that was filed under
README "Not yet".
A module declares a top-level theorem whose name matches the headline
pattern, but the name is **not pinned in any `Smoke.agda` via a `using (
… )` clause**. This enforces the estate *"every headline pinned in
Smoke"* discipline: a renamed or silently-dropped headline surfaces as a
missing pin rather than a quiet regression.
## Design
- **Warn severity** (per spec —
`missing-safe-pragma`/`orphan-module`/`unjustified-postulate` are the
hard-blocks; the rest are warns). Not every matching definition is a
headline the operator wants pinned, and the default pattern is
deliberately broad.
- **Headline detection** keys on top-level (column-0) type signatures
`name : T` (and the multi-name `a b c : T` form). Column-0-only gives
the **export-only filter for free**, since `private`-block definitions
are indented.
- **Pins** are the union of every `using ( … )` list across the
`Smoke.agda` files among the entry modules; tolerant of multi-line
`using` lists.
- **Self-skips** when no `Smoke.agda` is in scope (e.g. a single-file
`check`), and never lints a `Smoke.agda` for its own headlines.
- **Operator-configurable regex** via `--headline-pattern <regex>` on
`scan`/`dag`; default `^[a-z][A-Za-z0-9-]*$` per the spec open question.
The pattern lives on the **rule instance** (`UnpinnedHeadline { matcher
}`), so `LintContext` and every other rule's test constructor are
untouched.
## Changes
- New `src/lint/unpinned_headline.rs` (+ 12 unit tests).
- `RuleConfig` / `rules_with_config` in `src/lint/mod.rs`;
`default_rules()` unchanged in behaviour.
- `--headline-pattern` flag threaded through `scan`/`dag`.
- Adds the `regex` dependency.
- README + CHANGELOG updated; `unpinned-headline` removed from "Not
yet".
## Verification
- `cargo fmt --check`, `cargo clippy --all-targets -- -D warnings`,
`cargo build`, `cargo test` all green (lib suite 23 → 35).
- Dogfooded against the echo-types corpus: fires as a non-blocking
`warn` (432 hits under the broad default), pins read correctly from
`Smoke.agda` + `Ordinal/Buchholz/Smoke.agda`.
## Follow-ups (noted in README)
- Persist the headline pattern in `.arghda/config.toml` (currently a CLI
flag; config-discovery needs a small design decision since `scan`/`dag`
aren't workspace-scoped).
- Populate the DAG schema's per-node `headlines` array (the extractor
now exists).
🤖 Generated with [Claude Code](https://claude.com/claude-code)
https://claude.ai/code/session_019GiSiEfgZCte35dyykgBHs
---
_Generated by [Claude
Code](https://claude.ai/code/session_019GiSiEfgZCte35dyykgBHs)_8 files changed
Lines changed: 550 additions & 19 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
27 | 34 | | |
28 | 35 | | |
29 | 36 | | |
| |||
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| 17 | + | |
17 | 18 | | |
18 | 19 | | |
19 | 20 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
26 | 33 | | |
27 | 34 | | |
28 | 35 | | |
| |||
44 | 51 | | |
45 | 52 | | |
46 | 53 | | |
47 | | - | |
48 | | - | |
49 | | - | |
50 | | - | |
51 | | - | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
52 | 60 | | |
53 | 61 | | |
54 | 62 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
23 | | - | |
| 23 | + | |
24 | 24 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| 10 | + | |
10 | 11 | | |
11 | 12 | | |
12 | 13 | | |
| |||
25 | 26 | | |
26 | 27 | | |
27 | 28 | | |
28 | | - | |
29 | | - | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
30 | 50 | | |
31 | 51 | | |
32 | 52 | | |
33 | 53 | | |
34 | 54 | | |
35 | | - | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
36 | 65 | | |
37 | 66 | | |
38 | 67 | | |
| |||
0 commit comments