Skip to content

Executable line counting (exLOC) metrics: integrate into analyzer + context telemetry #204

@mojoatomic

Description

@mojoatomic

Summary
Implement executable line counting (exLOC) as the primary line metric for context-aware telemetry, while continuing to report physical lines for visibility. This aligns enforcement/assessment with real code changes and stops penalizing documentation.

Why

  • Physical lines penalize comments/docs and misrepresent refactors.
  • exLOC correlates better with complexity and health.

Prior Art

  • Prototypes in /line_count (EXECUTABLE-LINES.md, line-counter.js, analyzer-enhanced.js, tests).

Scope

  • Analyzer: compute and emit lines.physical, lines.executable, lines.comments, lines.commentRatio.
  • Telemetry (context-aware output): print deltas for physical vs executable and add a short assessment.
  • Configuration (.ai-coding-guide.json):
    • ratchet.lineCountMode: "executable" | "physical" (default: "executable" for telemetry; gating unaffected)
    • ratchet.metrics.trackPhysicalLines/trackExecutableLines/trackCommentRatio (booleans; default true)
  • CI: keep non-blocking; no gating changes in this issue.
  • Docs: add EXECUTABLE-LINES.md and a section in CONTEXT-AWARE-LINTING.md.
  • Tests: unit for line counting; integration snapshot for telemetry output.

Non-Goals (here)

  • Intent detection, domain-awareness, temporal trends (tracked separately; this lays the foundation).
  • Changing ESLint rule thresholds (we already skip comments in limits).

Implementation Plan

  • Create metrics/line-counter.js (production location) with removeComments/removeBlankLines/countExecutableLines/getLineMetrics.
  • Wire into analyze pipeline (bin/cli.js analyze) to populate metrics in analysis-current.json.
  • Update context-aware ratchet output to include Lines section with deltas (physical vs executable) and comment ratio.
  • Config: read ratchet.lineCountMode + metrics flags from .ai-coding-guide.json (fallbacks safe).
  • Unit tests for line-counter (ported from /line_count and aligned to production path).
  • Integration test: run lint:json + analyze:current and snapshot Lines section.
  • Docs: new docs/EXECUTABLE-LINES.md + link from CONTEXT-AWARE-LINTING.md.

Acceptance Criteria

  • Analysis outputs lines.physical, lines.executable, lines.comments, lines.commentRatio.
  • Context-aware run prints Lines block with deltas and clear assessment.
  • Gating remains unchanged (traditional ratchet only) pending Health Gating Enforcement for Context-Aware Ratchet #203.
  • Tests green; CI step non-blocking and visible.
  • Docs published.

Cross-links

Notes

  • Use /line_count prototypes as a starting point; refine regexes and edge cases over time.
  • We can later add language-aware parsing if needed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions