Skip to content

fix: strengthen duplicate prompt JSON enforcement; add prompt eval script - #130

Merged
kenjudy merged 2 commits into
mainfrom
feat/duplicate-prompt-fix-eval
Aug 31, 2026
Merged

kenjudy merged 2 commits into
mainfrom
feat/duplicate-prompt-fix-eval

Conversation

@kenjudy

@kenjudy kenjudy commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Live run (node local-code-metrics.js --history squashed) showed runSemanticDuplicateAnalysis returning prose ("Looking at...") instead of JSON, causing parse failure and status: unmeasured
  • Root cause: DUPLICATE_SYSTEM_PROMPT was missing the "no other text" clause that CLAUDE_SYSTEM_PROMPT and CFP_SYSTEM_PROMPT both carry
  • Adds no other text to the duplicate prompt's JSON instruction
  • Adds a prompt content test (DUPLICATE_SYSTEM_PROMPT instructs model to return no other text alongside the JSON)
  • Adds scripts/eval-prompts.js: a manual smoke-test that runs the CFP and duplicate prompts against the live API and asserts the responses are parseable JSON matching the expected schema; run before releasing any prompt change (ANTHROPIC_API_KEY=... node scripts/eval-prompts.js)

The commit analysis prompt (CLAUDE_SYSTEM_PROMPT) already carried "no other text" and has not been observed to fail; not touched here.

Test plan

  • __tests__/claudeAnalysis.test.js -- 1 new test: DUPLICATE_SYSTEM_PROMPT instructs model to return no other text alongside the JSON
  • 824/824 tests pass
  • node scripts/eval-prompts.js passes against live API (verified locally: 2 passed, 0 failed)

Generated with Claude Code

…ript

Live run showed runSemanticDuplicateAnalysis returning prose instead of
JSON despite "Respond ONLY" instruction. Added "no other text" clause to
DUPLICATE_SYSTEM_PROMPT, matching the enforcement pattern already present
in CLAUDE_SYSTEM_PROMPT and CFP_SYSTEM_PROMPT. Adds a prompt content test
and scripts/eval-prompts.js for manual smoke-testing all prompts against
the live API before releasing a prompt change.

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: 98 lines (2 files)
Test Code: 11 lines (1 files)
Total: 109 lines (3 files)
Test-to-Production Ratio: 0.11:1
No size or quality concerns.

Commit Analysis

Total Commits: 1
Average Commit Size: 98 production lines
Average Files per Commit: 3.0

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

Commit Details

6040604 Ken Judy (8/31/2026)
fix: strengthen duplicate prompt JSON enforcement; add prompt eval script
98 prod lines, 3 files [test+prod]

Test Coverage

Test-to-Production Ratio: 0.11: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.96 no band, see spec
Sample size (1 commit) 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

- Documents COSMIC-inspired CFP estimation in local script and PR comment
  sections (squashed history + ANTHROPIC_API_KEY required; informational only)
- Adds scripts/eval-prompts.js to file structure with usage note
- Corrects greenfield-modern band population from n=2 to n=6 (current per
  lib/thresholds.js line 184, grown by code-quality-metrics-vxr9)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@kenjudy
kenjudy merged commit 36780cd into main Aug 31, 2026
1 check passed
@kenjudy
kenjudy deleted the feat/duplicate-prompt-fix-eval branch August 31, 2026 21:59
@github-actions

Copy link
Copy Markdown

PR Analysis

Size: large (based on production code)
Production Code: 126 lines (3 files)
Test Code: 11 lines (1 files)
Total: 137 lines (4 files)
Test-to-Production Ratio: 0.09:1
No size or quality concerns.

Commit Analysis

Total Commits: 2
Average Commit Size: 63 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 1/2 (50%)
Message quality 2/2 (100%)
Median net additions ratio 0.63
Test-only commits 0
Production-only commits 1

Commit Details

6040604 Ken Judy (8/31/2026)
fix: strengthen duplicate prompt JSON enforcement; add prompt eval script
98 prod lines, 3 files [test+prod]

0ba0347 Ken Judy (8/31/2026)
docs: update README for CFP estimation, eval script, and greenfield n=6
28 prod lines, 1 files

Test Coverage

Test-to-Production Ratio: 0.09: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 50% >23% (no critical band established)
Version Control Message quality 100% no band, see spec
AI Risk Signal Net additions ratio (median) 0.63 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

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