Skip to content

feat(adf): per-path source LOC budgets to catch god-object drift (#186)#194

Merged
stackbilt-admin merged 1 commit into
mainfrom
feat/186-loc-budgets
May 30, 2026
Merged

feat(adf): per-path source LOC budgets to catch god-object drift (#186)#194
stackbilt-admin merged 1 commit into
mainfrom
feat/186-loc-budgets

Conversation

@stackbilt-admin
Copy link
Copy Markdown
Member

Refs #186. (Intentionally Refs, not Closes — see scoping note below.)

The ADF entry_loc metric only caps the single entry file, so other runtime source files can grow unchecked while the gate still passes (the reporter saw src/index.ts reach 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 generalizing 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), 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. 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

  • 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. This is why this is Refs not Closes: 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 in doctor + 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

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>
@stackbilt-admin stackbilt-admin merged commit e1dcbd9 into main May 30, 2026
5 checks passed
@stackbilt-admin stackbilt-admin deleted the feat/186-loc-budgets branch May 30, 2026 19:33
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.

feat(adf): add source LOC budget enforcement to catch godobject drift

1 participant