Skip to content

fix: replace unbounded additions ratio with bounded net additions ratio#31

Merged
kenjudy merged 1 commit into
mainfrom
24-additions-ratio-fix-the-net-new-file-inflation-problem-high-priority
Apr 7, 2026
Merged

fix: replace unbounded additions ratio with bounded net additions ratio#31
kenjudy merged 1 commit into
mainfrom
24-additions-ratio-fix-the-net-new-file-inflation-problem-high-priority

Conversation

@kenjudy
Copy link
Copy Markdown
Contributor

@kenjudy kenjudy commented Apr 7, 2026

The previous formula (additions / max(deletions, 1)) inflated ratios to ~500 for net-new-file commits, distorting both median and p90. The RETROSPECTIVE documented p90=446x as dominated by this artifact.

New formula: (additions - deletions) / (additions + deletions), bounded [-1, +1]. Value 1.0 = entirely net-new code; 0.0 = balanced; negative = net cleanup. Equivalent threshold: old 3.0 → new 0.50 (mathematically derived: when additions = 3×deletions, (3d-d)/(3d+d) = 0.50).

Changes:

  • local-code-metrics.js: replace ratio formula, rename summary fields additions_ratio_* → net_additions_ratio_*
  • .github/workflows/code-metrics.yml: same formula fix and field rename, update issue body threshold display, clean up redundant sort+map
  • .github/workflows/pr-metrics.yml: fix || 1 bug in deletions variable, rename per-commit field, update median ratio threshold and display
  • metrics-specification.md: rewrite Metric 7 with new formula, bounded range explanation, remapped thresholds, rejection rationale
  • tests/collectLocalMetrics.test.js: add regression test asserting median ≤ 1.0 for all-new-file commits; update field name assertions

The previous formula (additions / max(deletions, 1)) inflated ratios to
~500 for net-new-file commits, distorting both median and p90. The
RETROSPECTIVE documented p90=446x as dominated by this artifact.

New formula: (additions - deletions) / (additions + deletions), bounded
[-1, +1]. Value 1.0 = entirely net-new code; 0.0 = balanced; negative =
net cleanup. Equivalent threshold: old 3.0 → new 0.50 (mathematically
derived: when additions = 3×deletions, (3d-d)/(3d+d) = 0.50).

Changes:
- local-code-metrics.js: replace ratio formula, rename summary fields
  additions_ratio_* → net_additions_ratio_*
- .github/workflows/code-metrics.yml: same formula fix and field rename,
  update issue body threshold display, clean up redundant sort+map
- .github/workflows/pr-metrics.yml: fix || 1 bug in deletions variable,
  rename per-commit field, update median ratio threshold and display
- metrics-specification.md: rewrite Metric 7 with new formula, bounded
  range explanation, remapped thresholds, rejection rationale
- __tests__/collectLocalMetrics.test.js: add regression test asserting
  median ≤ 1.0 for all-new-file commits; update field name assertions

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@kenjudy kenjudy linked an issue Apr 7, 2026 that may be closed by this pull request
@kenjudy kenjudy merged commit 2f82eb4 into main Apr 7, 2026
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 7, 2026

PR Analysis

Size: small (based on production code)
Production Code: 92 lines (5 files)
Test Code: 38 lines (1 files)
Total: 130 lines (6 files)
Test-to-Production Ratio: 0.41:1

Concerns

  • 1/1 commits touch more than 5 files

Strengths

  • Strong test-first discipline across commits
  • Message quality 100% meets discipline threshold

Commit Analysis

Total Commits: 1
Average Commit Size: 92 production lines
Average Files per Commit: 6.0

Metric Value
Large commits (>100 prod lines) 0/1 (0%)
Sprawling commits (>5 files) 1/1 (100%)
Test-first discipline 1/1 (100%)
Message quality 1/1 (100%)
Median net additions ratio 0.49
Test-only commits 0
Production-only commits 0

Commit Details

e8b0d14 Ken Judy (4/7/2026)
fix: replace unbounded additions ratio with bounded net additions ratio
92 prod lines, 6 files [sprawling, test+prod]

Test Coverage

Test Adequacy: good

  • Good balance of production and test code

Target ratio: 0.5-2.0 test lines per production line

DORA Capability Assessment

Archetype: mixed-signals
No clear archetype pattern. Review individual metric thresholds.

Capability Metric Value Target
Small Batches Large commit % 0% <20%
Small Batches Sprawling commit % 100% <10%
Version Control Test-first discipline 100% >50%
Version Control Message quality 100% >60%
AI Risk Signal Net additions ratio (median) 0.49 <0.50
Automated by Code Metrics Workflow

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.

Additions Ratio: Fix the Net-New-File Inflation Problem (High Priority)

1 participant