Skip to content

fix(gate): catch fabricated delta-style counter claims - #1010

Open
wakqasahmed wants to merge 1 commit into
alirezarezvani:devfrom
wakqasahmed:fix/issue-995-delta-counter-check
Open

wakqasahmed wants to merge 1 commit into
alirezarezvani:devfrom
wakqasahmed:fix/issue-995-delta-counter-check

Conversation

@wakqasahmed

Copy link
Copy Markdown

Summary

derive_counters.py --check gates absolute totals in five named files, but counter prose in CHANGELOG.md and CLAUDE.md's release-note history sits entirely outside it — CHANGELOG.md was never read by this gate at all, and CLAUDE.md was only scanned on its two **Current Scope:**/**Status:** lines, not the release-note body where every past Counters: skills N → M entry actually lives. A fabricated delta (e.g. commands 147 → 150 for a one-command change) passes CI green in both files, exactly as reported in #995.

Fix

A one-directional invariant: since every one of these counters only grows over the repo's life, no delta claim's right-hand (new) value can legitimately exceed today's derived total. That's checkable without knowing which changelog entry is "current" — an equality check would fail on every legitimate historical entry describing a past, already-superseded state, which is most of what's in the file. extract_delta_claims/check_delta_claims implement this, scanning both CHANGELOG.md and the full text of CLAUDE.md (not just the two summary lines) for either arrow order ("skills 358 → 359" or "402 → 441 stdlib Python tools"), unicode or ASCII arrow.

Testing

  • scripts/test_derive_counters.py (new, stdlib unittest): the exact repro from derive_counters.py --check gates absolute totals but not delta claims, and never reads CHANGELOG.md #995 (both arrow styles) is rejected; a genuinely correct delta passes; an absolute/unchanged entry passes; a claim in a neighboring clause on the same line isn't cross-attributed to the wrong counter.
  • Ran the actual repro against the real repo tree: appending the issue's fabricated Counters: skills 999 → 1234; commands 12 → 999. line to CHANGELOG.md now correctly fails --check; reverting it back to the clean tree passes clean (no false positives against the repo's own legitimate multi-year changelog history).
  • Wired test_derive_counters.py into ci-quality-gate.yml (gate G3) so a future regression to the delta-claim logic itself gets caught, not just the original absolute-total check.

Closes #995.


Implemented with AI assistance (Claude Code).

…d/CLAUDE.md

derive_counters.py --check gated absolute totals in five files but never
read CHANGELOG.md, and only scanned CLAUDE.md's two 'Current Scope'/
'Status' lines rather than its release-note history — so a fabricated
delta claim like 'commands 147 -> 150' for a one-command change passed
CI green in both files (issue alirezarezvani#995).

Add a one-directional check: since every tracked counter only grows
over the repo's life, no delta claim's right-hand (new) value can
legitimately exceed today's derived total. That's enforceable without
knowing which changelog entry is 'current' and without touching any
of the existing, correct historical entries -- unlike an equality
check, which would fail on entirely legitimate past deltas.

Wires scripts/test_derive_counters.py into CI so a future regression
to the new delta-claim logic is caught, not just the absolute-total
gate it already ran.
@wakqasahmed

Copy link
Copy Markdown
Author

Hi @alirezarezvani — noticed this PR doesn't have a reviewer assigned yet — it's been sitting for a while, CI is green and it's mergeable. Would you (or whoever's best placed) be able to take a look, or point me to who should? Thanks!

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