fix(CostTracker): don't classify package.json SDK deps as BYPASS call sites#1318
Closed
ugiya wants to merge 1 commit into
Closed
fix(CostTracker): don't classify package.json SDK deps as BYPASS call sites#1318ugiya wants to merge 1 commit into
ugiya wants to merge 1 commit into
Conversation
…fests classifyCallSite() special-cased .md as non-executable but never handled dependency manifests. An @anthropic-ai/* entry in a package.json under a scan root matched a RISK_PATTERN, fell through to the 'SDK' branch, and was misclassified as a BYPASS call site — a false positive that fires a phantom cost alert against an empty/stale baseline. Mirror the existing .md rule for package.json / package-lock.json / bun.lock / bun.lockb / yarn.lock. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
classifyCallSite()inCostTracker.tsspecial-cases.mdfiles as non-executable, but never handled dependency manifests. When apackage.jsonunder a scan root (e.g.PULSE/,skills/) lists@anthropic-ai/*as a dependency, the@anthropic-ai/...RISK_PATTERNmatches the manifest text; the file isn't.md, isn't inLEGIT_HINTS, and has noANTHROPIC_API_KEY-delete guard, so it falls through to the"SDK"branch and is misclassified as abypasscall site.Result: a phantom "N call site(s) classified as BYPASS — review and patch" cost alert — even though a dependency declaration never executes and never bills. The real runtime callers (e.g.
PULSE/modules/telegram.ts,imessage.ts) are already correctly classifiedlegitvia thedelete process.env.ANTHROPIC_API_KEYguard.Reproduce
With
@anthropic-ai/claude-agent-sdkdeclared inPULSE/package.json:That line is a manifest dependency, not a call site → false positive (and it fires the BYPASS alert).
Fix
Mirror the existing
.mdrule for dependency manifests / lockfiles (package.json,package-lock.json,bun.lock,bun.lockb,yarn.lock): they declare packages, they don't execute, so an SDK name appearing in them is a declaration, not a billing call site.After the fix:
package.jsonclassifieslegit,bypass: 0,alert-check→ no alerts. Genuine executable risk patterns (SDK usage in.tswithout the guard,claude --bare, rawx-api-keyHTTP) still fire as before.Note
In this repo
CostTracker.tscurrently lives only atReleases/v5.0.0/.claude/PAI/TOOLS/CostTracker.ts, so the fix is applied there. Happy to retarget if there's a canonical source location elsewhere.🤖 Generated with Claude Code