Skip to content

#11: auto-prune stale snoozes on full-repo runs - #34

Merged
devill merged 4 commits into
mainfrom
issue-11-auto-prune
Jun 17, 2026
Merged

#11: auto-prune stale snoozes on full-repo runs#34
devill merged 4 commits into
mainfrom
issue-11-auto-prune

Conversation

@devill

@devill devill commented Jun 16, 2026

Copy link
Copy Markdown
Collaborator

Closes #11.

When a baselined (snoozed) smell is actually fixed, its .habit-hooks-baseline.json entry was left behind forever — toil that erodes trust in the baseline. This auto-prunes those dead entries on full-repo runs.

Locked decisions

  • 11.1 (default-on): auto-prune is on by default but fires only on a full-repo run, and prints the pruned set (never a silent mutation). A scoped/changed-files run is a guaranteed no-op — a file can look "clean" simply because its smell is outside the diff, so pruning there would silently un-snooze a real smell.
  • 11.2 (one reaper): reapBaseline is shared by manual baseline prune and auto-prune.

Design

run() stays a pure evaluator (it now reports scopeMode). Auto-prune is a CLI-orchestrated side effect in runWithAutoPrune: it runs only when scopeMode === 'all', does a baseline-free full scan (so a sensor gated off by the baseline can't make a snoozed file look falsely clean), reaps via the shared reaper, saves, and appends a coaching line listing what was pruned.

Atomic commits

  1. #11: extract rule-file matching into its own module — pure move (buildMatcher/filterFilesForRulesrc/rule-files.ts) to free room under the 200-line cap.
  2. #11: extract a shared baseline reaperreapBaseline returns kept entries + pruned paths; manual prune reuses it.
  3. #11: auto-prune fixed baseline entries on full-repo runs — the auto-prune module, scopeMode, CLI wiring, tests, DECISIONS.md.

Tests

Real git repo + real eslint: full-repo prune of a now-clean file (with the report), scoped run no-op even when the file is clean and in-scope, and not over-pruning a still-violating file.

Note

A baseline-free scan that hits a sensor spawn failure could read a file as falsely clean (pre-existing in manual baseline prune too). Once #25 lands, auto-prune can skip pruning when a sensor failed — a natural follow-up.

Gates

  • pnpm build, pnpm lint — clean
  • pnpm test — 388 passed (+3)

🤖 Generated with Claude Code


Generated by Claude Code

claude and others added 4 commits June 17, 2026 16:54
deps) out of runner.ts into src/rule-files.ts. Pure relocation, no
behaviour change; runner.ts was at the line cap and include/exclude
matching is a distinct concern.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Nq6xHU6JtSNpYWhMYjXB15
Move the keep/prune decision out of baselinePrune into reapBaseline
(src/baseline/reap.ts), which returns both the kept entries and the
pruned paths. Manual prune now reports the pruned count from it; the
upcoming auto-prune reuses the same reaper.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Nq6xHU6JtSNpYWhMYjXB15
On a full-repo run (run() now reports scopeMode), runWithAutoPrune does a
baseline-free full scan and reaps entries whose file is present but no
longer produces findings, printing the pruned set. A scoped run never
mutates the baseline (a file can look clean only because its smell is
outside the diff), so it is a guaranteed no-op.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Nq6xHU6JtSNpYWhMYjXB15
…e rules as the main run

Without this fix, autoPruneFullRepo always called run() without configPath,
falling back to default config discovery. When a user passes --config <custom>,
the re-scan could evaluate files under different rules than the main run —
causing the pruner to wrongly keep or prune baseline entries depending on
which config includes/excludes a given file.

Adds a test: a custom config that excludes bad.ts from scope; without the fix
the re-scan (default config, no exclusion) finds bad.ts violating and keeps
the stale baseline entry; with the fix the re-scan uses the same custom config,
respects the exclusion, and correctly prunes the entry.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@devill
devill force-pushed the issue-11-auto-prune branch from 2932aa6 to 7022739 Compare June 17, 2026 15:01
@devill
devill marked this pull request as ready for review June 17, 2026 15:02
@devill
devill merged commit 97d0372 into main Jun 17, 2026
2 checks passed
@devill
devill deleted the issue-11-auto-prune branch June 19, 2026 12:21
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.

Auto-prune stale snoozes from the baseline on full-repo runs

2 participants