Skip to content

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

Closed

Description

@stackbilt-admin

Summary

Charter ADF checks can pass while very large source files continue growing, unless teams explicitly configure additional LOC sync entries.

In practice this let src/index.ts in opsbrain reach 1600+ LOC without the Charter gate failing, despite repo governance intent to avoid godobjects.

Why this matters

Teams can believe they are fully covered by Charter's default pre-commit gate, but still miss high-risk architecture drift (godobject growth) because only entry_loc is enforced by default.

Repro (from real repo usage)

  1. Repo has Charter wiring + pre-commit hook enabled.
  2. Add many routes to one entry file (src/index.ts) until it exceeds intended team threshold.
  3. Run:
    • npx charter doctor --adf-only --ci --format text
    • npx charter adf evidence --auto-measure --ci
  4. Output still reports PASS with entry_loc only, unless custom sync constraints were manually configured.

Observed output shape

  • Constraints: [ok] entry_loc: 0 / 500 [lines] -- PASS
  • No default warning/failure about oversized runtime source files.

Expected

At minimum, one of:

  • A built-in optional policy profile for source LOC ceilings (for common patterns like src/index.ts, route files, service classes), or
  • A clear warning during doctor/evidence when only entry_loc is enforced and no runtime LOC ceilings exist, or
  • A first-class Charter config block to define per-path LOC budgets with sane defaults + explicit fail/warn behavior.

Proposed acceptance criteria

  • Add a documented + supported way to enforce source-file LOC budgets without custom scripts.
  • charter doctor surfaces when LOC coverage is effectively absent for runtime source files.
  • Teams can select warn vs fail policy per path pattern.

Activity

  1. added
    enhancement
    area:adf
    type:feature
    priority:p1
    on May 24, 2026
  2. stackbilt-admin commented on May 30, 2026

    @stackbilt-admin
    MemberAuthor

    Shipped in #194 (commit e1dcbd9). Quick usage + one scoping note so the rollout isn't surprising:

    How to use — declare per-path budgets in .charter/config.json:

    {
      "locBudgets": {
        "defaultWarn": 300,
        "defaultFail": 600,
        "paths": [
          { "pattern": "src/index.ts", "warn": 200, "fail": 500, "reason": "entry should stay thin" },
          { "pattern": "src/**", "warn": 300, "fail": 600 }
        ]
      }
    }

    charter doctor then measures matching files. Over the fail ceiling → WARN (fails CI under --ci); over warn only → advisory INFO (never fails CI). First matching pattern wins; per-rule ceilings fall back to the defaults.

    Scoping note (important): enforcement lives in charter doctor — the pre-commit/CI gate that loads .charter/config.json. charter adf evidence --auto-measure is intentionally unchanged; it's manifest-driven (reads .ai, not .charter) and still reports only the metrics declared in manifest.adf. So re-running your original adf evidence repro will still show entry_loc only — that's expected; the god-object coverage is charter doctor --adf-only --ci.

    Opt-in / non-breaking: with no locBudgets block, nothing is enforced — doctor just emits a soft INFO nudge that only entry_loc is covered.

    Docs: docs/cli-reference.md → charter doctor → "Source LOC budgets". Closing as delivered; reopen if the doctor path doesn't cover your case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:adfenhancementpriority:p1type:feature

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions