feat(adf): per-path source LOC budgets to catch god-object drift (#186)#194
Merged
Conversation
The ADF entry_loc metric only caps the single entry file, so other runtime source files can grow unchecked while the gate still passes. Add opt-in per-path LOC budgets with independent warn/fail ceilings. Core (@stackbilt/adf, pure + tested): - evaluateLocBudgets / resolveBudgetStatus / matchPath — a minimal, dependency-free path glob (*, **) + dual-ceiling status resolution that generalizes validator.ts's single-ceiling semantics. - LocBudgetRule / LocBudgetResult types (plain serializable shapes, ready for the planned config Zod migration). CLI (@stackbilt/cli): - CharterConfig.locBudgets block (paths[] + defaultWarn/defaultFail + enabled), parsed via the existing interface/merge pattern. - charter doctor evaluates configured budgets (runs under --adf-only too): fail-tier breach → WARN (fails CI in --ci), warn-tier breach → advisory INFO. When no coverage is configured, a soft INFO nudge — deliberately not WARN, since doctor fails CI on any WARN and that would break every repo that hasn't opted in. Design notes for review: - Two LOC-coverage sources now exist (manifest METRICS + config locBudgets); the coverage nudge counts either as satisfying coverage. - Enforcement lives in doctor (the pre-commit/CI gate that loads .charter config); adf evidence is unchanged (it reads .ai, not .charter). Tests: 16 core (status/glob/eval) + 5 doctor integration (fail→exit 1, warn→exit 0, pass, no-coverage nudge, enabled:false). Full suite 569 green. Refs #186 (enforcement via charter doctor + locBudgets config; adf evidence intentionally separate) Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Refs #186. (Intentionally
Refs, notCloses— see scoping note below.)The ADF
entry_locmetric only caps the single entry file, so other runtime source files can grow unchecked while the gate still passes (the reporter sawsrc/index.tsreach 1600+ LOC). Adds opt-in per-path LOC budgets with independent warn/fail ceilings.Core —
@stackbilt/adf(pure + tested)evaluateLocBudgets/resolveBudgetStatus/matchPath— a minimal, dependency-free path glob (*,**) + dual-ceiling status resolution generalizingvalidator.ts's single-ceiling semantics.LocBudgetRule/LocBudgetResulttypes — plain serializable shapes, ready for the planned config Zod migration.CLI —
@stackbilt/cliCharterConfig.locBudgetsblock (paths[]+defaultWarn/defaultFail+enabled), via the existing interface/merge pattern.charter doctorevaluates configured budgets (runs under--adf-onlytoo): fail-tier breach → WARN (fails CI in--ci), warn-tier breach → advisory INFO. With no coverage configured, a soft INFO nudge — deliberately not WARN, since doctor fails CI on any WARN and that would break every repo that hasn't opted in.Design notes for review
locBudgets); the coverage nudge counts either as satisfying coverage.doctor(the pre-commit/CI gate that loads.charterconfig).adf evidenceis unchanged — it reads.ai, not.charter. This is why this isRefsnotCloses: the reporter's repro ran both commands, so close feat(adf): add source LOC budget enforcement to catch godobject drift #186 manually noting enforcement is indoctor+ config.Tests
16 core (status/glob/eval) + 5 doctor integration (fail→exit 1, warn→exit 0, pass, no-coverage nudge,
enabled:false). Full suite 569 green; typecheck clean.🤖 Generated with Claude Code