Repository navigation
feat: all three guards from #63 (smoke alarm, non-zero exit, reconciliation invariant) - #120
Conversation
calibration/observations.json: 30 observation records share the same JSON schema -- a single repeated structure with nothing to refactor. Without this exclusion, jscpd reports ~4.8% duplication, nearly all from this one file. This follows the same rationale as the built-in DUPLICATE_IGNORE_PATTERNS entries (vendored and generated files repeat by design). .github/: CI workflow definitions repeat setup steps across jobs by design, same as the built-in vendored/generated exclusions. Measured effect: duplication falls from ~4.8% to ~1.57% (test fixture patterns sharing structure across workflow test files), below the 2% healthy band. The 1.57% is genuine; the 4.8% was calibration-data noise. Note the deliberate near-collision: a tracked .codemetrics.json file and an ignored .codemetrics/ output directory coexist -- different filesystem entries, shared prefix intentional (see CLAUDE.md Output Location section). Closes code-quality-metrics-0a3m Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
… check A per-ref loop summing git rev-list --count results counted shared commits once per branch, producing a 21x overcount on repositories with many late- diverging branches (596 unique commits reported as 12,450). Passing all refs to a single rev-list call lets git deduplicate shared history, matching what fetchBranchCommits actually returns. Closes code-quality-metrics-u2eq. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…(Guard 1, #63) Adds looksLikeTestPath() to lib/metrics.js: matches any path with test/, tests/, spec/, specs/, or __tests__/ as a segment. analyzeCommit now collects suspect_test_paths[] for production-classified files that look like test directories. local-code-metrics.js aggregates them into the summary JSON and emits a named console warning listing the paths. The warning is informational only; no metric value changes. The spec/ gap it surfaces is real: TEST_FILE_PATTERNS covers test/ and tests/ via (^|\/)tests?\// but has no entry for spec/ as a bare directory segment. Closes code-quality-metrics-juy7. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…opulation (Guard 2, #63) local-code-metrics.js: logNoCommitsAnalyzed() now calls process.exit(1) after logging, so any run that finds no analyzable commits -- whether uniqueCommits is empty or every commit fails analysis -- exits non-zero rather than returning 0 with no output written. derive-bands.js: new checkPopulationSize() exits 1 with a named error when the selected population has fewer than 2 usable observations, preventing a silent empty-bands output. Called from main() immediately after filtering usable observations. Updated five collectLocalMetrics tests that expected the old silent-return behavior; added three new checkPopulationSize unit tests covering 0, 1, and >=2 observation counts. Total tests: 745 → 748. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…d 3, #63) Two new invariant tests assert files_changed === excluded_files_count + counted_files_changed across an all-prod case and a mixed test+prod+excluded case. The partition is exact: excluded and non-excluded files account for the total regardless of binary presence. If any classification branch is added or removed without updating the counters, at least one invariant will fail. Both tests pass green on the current (correct) implementation. Total tests: 748 → 750. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
PR AnalysisSize: small (based on production code) Strengths
Commit AnalysisTotal Commits: 5
Commit Details3993820 Ken Judy (8/31/2026) f09f490 Ken Judy (8/31/2026) ab703fe Ken Judy (8/31/2026) eb9a40e Ken Judy (8/31/2026) e57fb20 Ken Judy (8/31/2026) Test CoverageTest-to-Production Ratio: 3.36:1 (no calibrated target for this ratio; reported descriptively) DORA Capability AssessmentArchetype: harmonious-high-achiever
|
Summary
Implements all three guards from GitHub #63 across three atomic commits:
Guard 1 (
ab703fe):looksLikeTestPathsmoke alarm surfaces production-classified files whose path segments look like test directories (e.g.src/spec/utils.jsslipping throughTEST_FILE_PATTERNS). Warns on console; never used as a metric input.Guard 2 (
eb9a40e):logNoCommitsAnalyzed()now callsprocess.exit(1)after logging, so any run that finds zero analyzable commits exits non-zero rather than returning 0 silently. Also addscheckPopulationSize()toderive-bands.js, exiting 1 with a named error when a population has fewer than 2 usable observations.Guard 3 (
e57fb20): Two new reconciliation invariant tests assertfiles_changed === excluded_files_count + counted_files_changedacross an all-prod case and a mixed test+prod+excluded case. No production code changes.Test plan
npm testpasses (745 → 750 tests)looksLikeTestPathtests in__tests__/looksLikeTestPath.test.jsand three newanalyzeCommittestscollectLocalMetricsearly-exit tests updated to expectprocess.exit(1); three newcheckPopulationSizeunit testsCloses #63.
🤖 Generated with Claude Code