Skip to content

feat(#124): COSMIC FP approximation in pr-metrics.yml - #126

Merged
kenjudy merged 2 commits into
mainfrom
feat/cfp-pr-metrics-124
Aug 31, 2026
Merged

kenjudy merged 2 commits into
mainfrom
feat/cfp-pr-metrics-124

Conversation

@kenjudy

@kenjudy kenjudy commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Adds CFP_SYSTEM_PROMPT and analyzeCfpWithClaude(client, files) to lib/claude.js; counts Entry/Exit/Read/Write data movements from the PR diff and returns { estimated_cfp_delta, estimated_cfp_breakdown }
  • Wires it into pr-metrics.yml: called after semantic duplicate analysis, gated on anthropicClient !== null
  • Adds an "Estimated Functional Size (COSMIC-inspired approximation)" section to the PR comment when the result is non-null; section is omitted when key is absent or estimation fails
  • Informational only: labeled as approximation, no calibrated target established

Test plan

  • __tests__/claudeAnalysis.test.js -- 6 new tests for analyzeCfpWithClaude: happy path, null client, API error, malformed JSON, prompt content, markdown fence stripping
  • __tests__/prMetricsCfp.test.js -- 3 new workflow-level tests: CFP section appears when client available, omitted when client null, omitted when function returns null
  • All 815 existing tests continue to pass

🤖 Generated with Claude Code

kenjudy and others added 2 commits August 31, 2026 17:14
…m PR diff

Add CFP_SYSTEM_PROMPT and analyzeCfpWithClaude(client, files) to lib/claude.js.
Returns { estimated_cfp_delta, estimated_cfp_breakdown } counting E/X/R/W data
movements from the PR diff; returns null on skip or error. Six tests cover the
happy path, null-client skip, API error, malformed JSON, prompt content, and
markdown fence stripping.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Call analyzeCfpWithClaude(anthropicClient, files) after semantic duplicate
analysis; render an Estimated Functional Size section in the PR comment when
the result is non-null. Section is omitted when ANTHROPIC_API_KEY is absent or
the estimation fails. Labeled COSMIC-inspired approximation, informational only,
no calibrated target.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown

PR Analysis

Size: small (based on production code)
Production Code: 76 lines (2 files)
Test Code: 218 lines (2 files)
Total: 294 lines (4 files)
Test-to-Production Ratio: 2.87:1
No size or quality concerns.

Commit Analysis

Total Commits: 2
Average Commit Size: 38 production lines
Average Files per Commit: 2.0

Metric Value
Large commits (>100 prod lines) 0/2 (0%)
Sprawling commits (>5 files) 0/2 (0%)
Test/prod co-change rate 2/2 (100%)
Message quality 2/2 (100%)
Median net additions ratio 0.98
Test-only commits 0
Production-only commits 0

Commit Details

a5d4d75 Ken Judy (8/31/2026)
test(#124): RED/GREEN analyzeCfpWithClaude — COSMIC FP estimation from PR diff
59 prod lines, 2 files [test+prod]

d09eb85 Ken Judy (8/31/2026)
feat(#124): wire analyzeCfpWithClaude into pr-metrics.yml PR comment
17 prod lines, 2 files [test+prod]

Test Coverage

Test-to-Production Ratio: 2.87:1 (no calibrated target for this ratio; reported descriptively)

DORA Capability Assessment

Archetype: harmonious-high-achiever
Strong batch discipline, test coverage, and message quality. AI tools likely amplifying positive outcomes.

Capability Metric Value Target
Small Batches Large commit % 0% <18% (no critical band established)
Small Batches Sprawling commit % 0% <18% (no critical band established)
Version Control Test/prod co-change rate 100% >23% (no critical band established)
Version Control Message quality 100% no band, see spec
AI Risk Signal Net additions ratio (median) 0.98 no band, see spec
Sample size (2 commits) is below the 5-commit convention for a rate verdict (code-quality-metrics-w9f): large-commit %, sprawling-commit % and test/prod co-change rate are reported below without a pass/fail judgement.
Automated by Code Metrics Workflow

@kenjudy
kenjudy merged commit 8b6fd12 into main Aug 31, 2026
1 check passed
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.

1 participant