scorchmark 0.6.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- scorchmark-0.6.0/.gitignore +20 -0
- scorchmark-0.6.0/LICENSE +21 -0
- scorchmark-0.6.0/PAYMENTS.md +98 -0
- scorchmark-0.6.0/PKG-INFO +305 -0
- scorchmark-0.6.0/README.md +274 -0
- scorchmark-0.6.0/SECURITY.md +70 -0
- scorchmark-0.6.0/adapters.py +131 -0
- scorchmark-0.6.0/alerts.py +136 -0
- scorchmark-0.6.0/cli.py +318 -0
- scorchmark-0.6.0/conftest.py +5 -0
- scorchmark-0.6.0/detectors.py +520 -0
- scorchmark-0.6.0/examples/sample_cost_log.jsonl +9 -0
- scorchmark-0.6.0/ingest.py +157 -0
- scorchmark-0.6.0/licensing.py +141 -0
- scorchmark-0.6.0/pricing.py +125 -0
- scorchmark-0.6.0/pricing_drift.py +144 -0
- scorchmark-0.6.0/pyproject.toml +63 -0
- scorchmark-0.6.0/scripts/issue_license.py +66 -0
- scorchmark-0.6.0/scripts/stripe_webhook.py +106 -0
- scorchmark-0.6.0/server.py +392 -0
- scorchmark-0.6.0/tests/test_agentspend.py +901 -0
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# Python
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
.venv/
|
|
5
|
+
venv/
|
|
6
|
+
.pytest_cache/
|
|
7
|
+
*.egg-info/
|
|
8
|
+
build/
|
|
9
|
+
dist/
|
|
10
|
+
|
|
11
|
+
# Local runtime state (pricing-drift history, logs, ingested data)
|
|
12
|
+
*.tmp
|
|
13
|
+
*.log
|
|
14
|
+
pricing_history.json
|
|
15
|
+
.DS_Store
|
|
16
|
+
|
|
17
|
+
# Secrets — NEVER commit the license signing private key (defense in depth)
|
|
18
|
+
.secrets/
|
|
19
|
+
*signing_key*
|
|
20
|
+
*.pem
|
scorchmark-0.6.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Anas (github.com/Nas01010101)
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
# Getting paid — Scorchmark
|
|
2
|
+
|
|
3
|
+
Two channels. Use either or both. The **MCPize** path is the fastest to revenue;
|
|
4
|
+
the **self-serve Stripe + license** path keeps ~97% and works for direct GitHub/PyPI users.
|
|
5
|
+
|
|
6
|
+
| | MCPize (managed) | Self-serve (Stripe + license key) |
|
|
7
|
+
|---|---|---|
|
|
8
|
+
| You keep | 80% (MCPize takes 20%) | ~97% (Stripe ~2.9%+30¢) |
|
|
9
|
+
| Hosting | MCPize hosts the server | user self-hosts (or MCPize too) |
|
|
10
|
+
| Billing/gating | MCPize meters + gates | this repo's license system |
|
|
11
|
+
| Setup effort | ~90 min + Stripe KYC | keypair (done) + Stripe Payment Links |
|
|
12
|
+
| Best for | discovery + hands-off | power users, teams, max margin |
|
|
13
|
+
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
## How the license system works
|
|
17
|
+
|
|
18
|
+
Free is the entire MIT core. The **Pro** and **Team** tools unlock with a signed
|
|
19
|
+
license key in `SCORCHMARK_LICENSE`. Verification is **offline** — an Ed25519
|
|
20
|
+
signature checked against the public key embedded in `licensing.py`. No phone-home,
|
|
21
|
+
so the "no outbound calls" security promise holds. Keys are unforgeable without the
|
|
22
|
+
private key (which only you hold).
|
|
23
|
+
|
|
24
|
+
**What each tier unlocks** (same in the MCP server and the `scorchmark` CLI):
|
|
25
|
+
|
|
26
|
+
| Tier | Tools |
|
|
27
|
+
|---|---|
|
|
28
|
+
| Free $0 | `ingest_run`, `check_budget`, `find_spend_anomalies`, `detect_cache_waste`, `predict_rate_limit`, `detect_stuck_agent`, `build_alert_payload`, pricing resource |
|
|
29
|
+
| Pro $19/mo | + `detect_spend_acceleration`, + webhook **alerting** (`check_budget(alert=True)`) |
|
|
30
|
+
| Team $49/mo | + `cost_by_agent`, + `simulate_model_swap`, + `detect_pricing_drift` |
|
|
31
|
+
|
|
32
|
+
A Team key satisfies a Pro requirement. Gated tools return an `upgrade_required`
|
|
33
|
+
object (not an error) pointing at the buy URL. Honest open-core: the source is MIT,
|
|
34
|
+
so a determined user can patch the gate out — the license keeps the tiers official
|
|
35
|
+
and funds the maintained pricing model. Most users are honest.
|
|
36
|
+
|
|
37
|
+
---
|
|
38
|
+
|
|
39
|
+
## Channel A — MCPize (managed)
|
|
40
|
+
|
|
41
|
+
1. List the repo on https://mcpize.com (reads `mcpize.yaml`).
|
|
42
|
+
2. Set the three tiers in the MCPize dashboard: **Free $0 / Pro $19 / Team $49**
|
|
43
|
+
(yearly $190 / $490). MCPize connects Stripe and gates by subscription itself —
|
|
44
|
+
the license system below is **not needed** on this path.
|
|
45
|
+
3. Stripe Connect KYC → payouts the 1st, 80% to you.
|
|
46
|
+
|
|
47
|
+
## Channel B — self-serve (Stripe Payment Links + license keys)
|
|
48
|
+
|
|
49
|
+
Generate an Ed25519 keypair. The **public** key is embedded in `licensing.py`; keep
|
|
50
|
+
the **private** key in a secure location *outside* the repo (e.g. `~/.secrets/`,
|
|
51
|
+
`chmod 600`, never committed — it's gitignored). Keep it safe — losing it means
|
|
52
|
+
re-issuing every key; leaking it means anyone can mint keys.
|
|
53
|
+
|
|
54
|
+
**One-time Stripe setup (dashboard, no code):**
|
|
55
|
+
1. Create two **Products/Prices**: Pro $19/mo, Team $49/mo (add yearly if you want).
|
|
56
|
+
2. Create a **Payment Link** for each. On each link set **metadata**:
|
|
57
|
+
`tier=pro` (or `team`) and `days=0` for a subscription the webhook re-issues, or
|
|
58
|
+
`days=365` for a fixed-term key. Collect the customer's email on the link.
|
|
59
|
+
3. Add a **webhook endpoint** → event `checkout.session.completed` → copy the
|
|
60
|
+
signing secret (`whsec_...`).
|
|
61
|
+
|
|
62
|
+
**Run the fulfilment webhook** (turns a payment into a delivered key):
|
|
63
|
+
```bash
|
|
64
|
+
export STRIPE_WEBHOOK_SECRET=whsec_...
|
|
65
|
+
export SCORCHMARK_SIGNING_KEY="$(cat ~/.secrets/scorchmark_signing_key.b64)"
|
|
66
|
+
# optional auto-email; without SMTP it just logs the key for you to send:
|
|
67
|
+
export SMTP_HOST=smtp.you.com SMTP_USER=... SMTP_PASS=... FROM_EMAIL=you@you.com
|
|
68
|
+
python3 scripts/stripe_webhook.py # listens on :8787, behind HTTPS in prod
|
|
69
|
+
```
|
|
70
|
+
On purchase it verifies Stripe's signature (HMAC-SHA256, stdlib), mints a signed
|
|
71
|
+
key, and emails it (or logs it).
|
|
72
|
+
|
|
73
|
+
**Or mint keys by hand** (manual sales, comps, testing):
|
|
74
|
+
```bash
|
|
75
|
+
SCORCHMARK_SIGNING_KEY="$(cat .../scorchmark_signing_key.b64)" \
|
|
76
|
+
python3 scripts/issue_license.py --tier team --email buyer@co.com --days 365
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
**What the customer does:**
|
|
80
|
+
```bash
|
|
81
|
+
pip install 'scorchmark[pro]' # adds offline-verify (cryptography)
|
|
82
|
+
export SCORCHMARK_LICENSE=SCM1..... # the key you sent
|
|
83
|
+
scorchmark license # → tier: TEAM · active
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
---
|
|
87
|
+
|
|
88
|
+
## Key operations
|
|
89
|
+
|
|
90
|
+
- **Renewal/subscriptions:** issue fixed-term keys (`--days 365`) and re-issue on
|
|
91
|
+
Stripe's renewal webhook, OR issue perpetual keys (`--days 0`) and rely on Stripe
|
|
92
|
+
to stop billing on cancel (the key keeps working — fine for low-priced honor-model
|
|
93
|
+
tiers; use short terms if you need hard expiry).
|
|
94
|
+
- **Revocation:** offline keys can't be individually revoked without rotating the
|
|
95
|
+
keypair (which invalidates *all* keys). For hard revocation use short terms +
|
|
96
|
+
renewal, or the MCPize managed path. Document this; don't pretend otherwise.
|
|
97
|
+
- **Rotation:** generate a new keypair, update `PUBLIC_KEY_B64` in `licensing.py`,
|
|
98
|
+
ship a release, re-issue active keys. Only do this if the private key leaks.
|
|
@@ -0,0 +1,305 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: scorchmark
|
|
3
|
+
Version: 0.6.0
|
|
4
|
+
Summary: Find the cache tax draining your AI bill: a cross-provider cache-TTL-waste detector + model-swap savings simulator + pricing-drift + per-agent attribution. MCP server + CLI.
|
|
5
|
+
Project-URL: Homepage, https://github.com/Nas01010101/scorchmark
|
|
6
|
+
Project-URL: Repository, https://github.com/Nas01010101/scorchmark
|
|
7
|
+
Project-URL: Issues, https://github.com/Nas01010101/scorchmark/issues
|
|
8
|
+
Author: Anas
|
|
9
|
+
License-Expression: MIT
|
|
10
|
+
License-File: LICENSE
|
|
11
|
+
Keywords: agents,anthropic,claude,cost,finops,llm,mcp,observability,openai,prompt-caching
|
|
12
|
+
Classifier: Development Status :: 4 - Beta
|
|
13
|
+
Classifier: Environment :: Console
|
|
14
|
+
Classifier: Intended Audience :: Developers
|
|
15
|
+
Classifier: Programming Language :: Python :: 3
|
|
16
|
+
Classifier: Topic :: Software Development :: Libraries
|
|
17
|
+
Classifier: Topic :: System :: Monitoring
|
|
18
|
+
Requires-Python: >=3.11
|
|
19
|
+
Provides-Extra: all
|
|
20
|
+
Requires-Dist: cryptography>=42.0; extra == 'all'
|
|
21
|
+
Requires-Dist: fastmcp>=3.0; extra == 'all'
|
|
22
|
+
Provides-Extra: dev
|
|
23
|
+
Requires-Dist: cryptography>=42.0; extra == 'dev'
|
|
24
|
+
Requires-Dist: fastmcp>=3.0; extra == 'dev'
|
|
25
|
+
Requires-Dist: pytest>=8.0; extra == 'dev'
|
|
26
|
+
Provides-Extra: mcp
|
|
27
|
+
Requires-Dist: fastmcp>=3.0; extra == 'mcp'
|
|
28
|
+
Provides-Extra: pro
|
|
29
|
+
Requires-Dist: cryptography>=42.0; extra == 'pro'
|
|
30
|
+
Description-Content-Type: text/markdown
|
|
31
|
+
|
|
32
|
+
<p align="center">
|
|
33
|
+
<picture>
|
|
34
|
+
<source media="(prefers-color-scheme: dark)" srcset="assets/logo-dark.svg">
|
|
35
|
+
<img src="assets/logo.svg" alt="Scorchmark" width="460">
|
|
36
|
+
</picture>
|
|
37
|
+
</p>
|
|
38
|
+
|
|
39
|
+
<p align="center"><strong>The scorch mark on your AI bill. Scorchmark finds the cache-rebuild waste, model-swap savings, and silent price hikes your provider dashboard won't show you — as an MCP tool + CLI.</strong></p>
|
|
40
|
+
|
|
41
|
+
<p align="center">
|
|
42
|
+
<img src="https://github.com/Nas01010101/scorchmark/actions/workflows/ci.yml/badge.svg" alt="CI">
|
|
43
|
+
<img src="https://img.shields.io/badge/license-MIT-blue.svg" alt="License: MIT">
|
|
44
|
+
<img src="https://img.shields.io/badge/MCP-server-7c3aed.svg" alt="MCP server">
|
|
45
|
+
<img src="https://img.shields.io/badge/tests-66%20passing-brightgreen.svg" alt="tests: 66 passing">
|
|
46
|
+
<img src="https://img.shields.io/badge/runtime%20deps-0-success.svg" alt="runtime deps: 0">
|
|
47
|
+
</p>
|
|
48
|
+
|
|
49
|
+
<p align="center">
|
|
50
|
+
<img src="assets/demo.gif" alt="Scorchmark catching runaway cache-rebuild spend live" width="760">
|
|
51
|
+
</p>
|
|
52
|
+
|
|
53
|
+
Your provider dashboard tells you *what* you spent — a day late. It never tells you *what you
|
|
54
|
+
wasted*: the cache rebuilds you re-paid for, the model that would have done the job for 40% less,
|
|
55
|
+
the silent price hike. Scorchmark reads a cost log you already have and finds that waste — starting
|
|
56
|
+
with the **cache-TTL waste behind the documented $6,000 overnight burn**, which no observability
|
|
57
|
+
tool we surveyed detects.
|
|
58
|
+
|
|
59
|
+
It answers the questions the dashboard can't: *where did the cache money go, which agent burned it,
|
|
60
|
+
and what would a cheaper model have saved?* Read-only and local — no proxy in your request path —
|
|
61
|
+
as an MCP tool your agent can call mid-run, or a one-line CLI.
|
|
62
|
+
|
|
63
|
+
| ❌ Without Scorchmark | ✅ With it |
|
|
64
|
+
|---|---|
|
|
65
|
+
| You find out from the limit email, a day late | The agent sees `warn` at wake-up #2, mid-run |
|
|
66
|
+
| Cache-TTL waste silently eats up to 90% of spend | `detect_cache_waste` flags it and prices the loss |
|
|
67
|
+
| No idea which agent burned the money | `cost_by_agent` attributes every dollar |
|
|
68
|
+
| "Should I have used a cheaper model?" stays unknowable | `simulate_model_swap` gives the exact saved % |
|
|
69
|
+
|
|
70
|
+
## Why this exists
|
|
71
|
+
|
|
72
|
+
Someone left Claude Code looping overnight to check PRs and woke up to a **$6,000 bill**. Not a bug
|
|
73
|
+
in their code. A cache-TTL change (1 hour down to 5 minutes) meant every 30-minute wake-up rebuilt
|
|
74
|
+
an 800k-token history at the cache *write* rate instead of the cheap cache *read*. The dashboard
|
|
75
|
+
showed nothing for days. The first warning was the limit email, after the money was gone.
|
|
76
|
+
|
|
77
|
+
The post got 1,400+ upvotes because everyone running unattended agents felt the cold sweat. And
|
|
78
|
+
there was no tripwire — every tool, including the provider's own dashboard, is retrospective.
|
|
79
|
+
|
|
80
|
+
Replaying that incident's shape through these tools:
|
|
81
|
+
|
|
82
|
+
```text
|
|
83
|
+
ingested 46 wake-ups total spend $265
|
|
84
|
+
detect_cache_waste 45 rebuilds, $237 wasted (90% of spend)
|
|
85
|
+
check_budget($50 cap) first 'warn' at wake-up #2 (burn $20/hr)
|
|
86
|
+
simulate_model_swap→Sonnet $265 would have been $159 (save 40%)
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
90% of that spend was avoidable, and a $50 cap would have tripped on the **second** wake-up, not the
|
|
90
|
+
46th. (Absolute dollars scale with your context size and loop length; the waste fraction and the
|
|
91
|
+
early catch are the point.)
|
|
92
|
+
|
|
93
|
+
## How it's different from Helicone / Langfuse / LangSmith
|
|
94
|
+
|
|
95
|
+
Those are good tools. They are also a different shape of thing.
|
|
96
|
+
|
|
97
|
+
| | Helicone | Langfuse / LangSmith | **Scorchmark** |
|
|
98
|
+
|---|---|---|---|
|
|
99
|
+
| Form factor | Proxy in your request path | SDK / OTel tracing + dashboard | **MCP tool the agent calls** |
|
|
100
|
+
| When you learn | Dashboard, after the call | Dashboard, after the run | **In the loop, before the next call** |
|
|
101
|
+
| Who acts on it | A human reading a chart | A human reading a trace | **The agent itself** |
|
|
102
|
+
| Cache-TTL waste | Not detected | Not detected | **Detected and priced** |
|
|
103
|
+
| In your critical path | Yes (all traffic routed) | No | No (read-only on your logs) |
|
|
104
|
+
| Setup | Swap base URL | Instrument SDK | Point it at a log file |
|
|
105
|
+
|
|
106
|
+
The wedge: those tools tell *you* what happened. Scorchmark tells the *agent* what's about to
|
|
107
|
+
happen, in a form it can act on without a human in the loop. It adds nothing to your request path —
|
|
108
|
+
it reads a cost log you already have.
|
|
109
|
+
|
|
110
|
+
And it is **not** a spend *cap*. Hard budget enforcement is a commodity now — Cloudflare AI Gateway,
|
|
111
|
+
LiteLLM, and Portkey all block-before-the-call. Scorchmark does the part they don't: it tells you
|
|
112
|
+
*where the money leaked and what to change*. Cap your spend with a gateway; find the cache tax with
|
|
113
|
+
this. It is also not a full observability platform — if you want flame-graph traces and prompt
|
|
114
|
+
evals, run Langfuse. Scorchmark is the cost-intelligence layer, and it composes fine with both.
|
|
115
|
+
|
|
116
|
+
## Quickstart
|
|
117
|
+
|
|
118
|
+
The CLI core is pure stdlib (install pulls nothing). The MCP server adds one extra:
|
|
119
|
+
|
|
120
|
+
```bash
|
|
121
|
+
uv sync --extra mcp # MCP server deps (FastMCP)
|
|
122
|
+
uv run fastmcp run server.py # stdio (Claude Desktop / Inspector)
|
|
123
|
+
uv run fastmcp run server.py --transport streamable-http --port 8000 # remote / MCPize
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
Add it to Claude Desktop / Cursor (`claude_desktop_config.json` or `.cursor/mcp.json`):
|
|
127
|
+
|
|
128
|
+
```json
|
|
129
|
+
{
|
|
130
|
+
"mcpServers": {
|
|
131
|
+
"scorchmark": {
|
|
132
|
+
"command": "uv",
|
|
133
|
+
"args": ["run", "fastmcp", "run", "/path/to/scorchmark/server.py"]
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
Then, in the loop:
|
|
140
|
+
|
|
141
|
+
```python
|
|
142
|
+
ingest_run(open("examples/sample_cost_log.jsonl").read())
|
|
143
|
+
check_budget(monthly_cap_usd=100, reset_day=1) # ok | warn | breach, with ETA to the reset
|
|
144
|
+
detect_cache_waste() # the $6k pattern
|
|
145
|
+
simulate_model_swap(to_model="claude-haiku-4-5") # exact per-row savings, cross-provider OK
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
## Try it in your terminal (no MCP client)
|
|
149
|
+
|
|
150
|
+
**Run it on your own Claude Code usage — zero setup, a log you already have:**
|
|
151
|
+
|
|
152
|
+
```bash
|
|
153
|
+
uvx --from scorchmark scorchmark report --claude-code
|
|
154
|
+
# reads ~/.claude/projects/**/*.jsonl directly and prices every request
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
That auto-adapts Claude Code's session transcripts — no reformatting. Or point it at any cost log:
|
|
158
|
+
|
|
159
|
+
```bash
|
|
160
|
+
uvx --from scorchmark scorchmark report mylog.jsonl --cap 100 # auto-detects the format
|
|
161
|
+
uv run scorchmark report examples/sample_cost_log.jsonl --cap 50 # from a clone
|
|
162
|
+
cat mylog.jsonl | uv run scorchmark swap - --to claude-haiku-4-5 # reads stdin
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
Subcommands: `report` (all checks), `budget`, `cache-waste`, `by-agent`, `anomalies`, `swap`.
|
|
166
|
+
Add `--json` for the raw result, `--from {auto,scorchmark,claude-code}` to force a format, or point
|
|
167
|
+
the log argument at a **directory** of `.jsonl` files. Same engine as the MCP server.
|
|
168
|
+
|
|
169
|
+
## See it run
|
|
170
|
+
|
|
171
|
+
Real output from `examples/sample_cost_log.jsonl` — the live `warn`, the cache-waste dollars, and
|
|
172
|
+
the per-agent breakdown the provider dashboard never shows you (these are actual tool results, not
|
|
173
|
+
mockups):
|
|
174
|
+
|
|
175
|
+

|
|
176
|
+
|
|
177
|
+

|
|
178
|
+
|
|
179
|
+

|
|
180
|
+
|
|
181
|
+
## Tools
|
|
182
|
+
|
|
183
|
+
### Core
|
|
184
|
+
|
|
185
|
+
| Tool | What it does |
|
|
186
|
+
|---|---|
|
|
187
|
+
| `ingest_run` | Load a cost-log JSONL. Computes cost from the bundled pricing model when absent. |
|
|
188
|
+
| `check_budget` | Live tripwire: spend, burn rate, projected spend to the next reset, `ok`/`warn`/`breach`, ETA to cap. |
|
|
189
|
+
| `find_spend_anomalies` | Flags requests costing N× the agent's median — the loop-spike signature. |
|
|
190
|
+
| `detect_cache_waste` | Detects cache waste, modeling each provider's real economics (see below) and pricing it. |
|
|
191
|
+
| `cost_by_agent` | Per-agent attribution: cost, share, requests, average per request. |
|
|
192
|
+
|
|
193
|
+
### Edge (not offered by any tool we surveyed)
|
|
194
|
+
|
|
195
|
+
| Tool | What it does |
|
|
196
|
+
|---|---|
|
|
197
|
+
| `detect_spend_acceleration` | Flags a burn rate that doubles across consecutive windows (runaway context growth). |
|
|
198
|
+
| `simulate_model_swap` | Recomputes every past request at another model's price for the row-exact savings. Cross-provider. |
|
|
199
|
+
| `detect_pricing_drift` | Snapshots provider rates and surfaces any silent change — the root cause of the $6k burn. |
|
|
200
|
+
|
|
201
|
+
### Match (parity with the heavy gateways)
|
|
202
|
+
|
|
203
|
+
| Tool | What it does |
|
|
204
|
+
|---|---|
|
|
205
|
+
| `predict_rate_limit` | Projects ETA to a 429 from rate-limit headers, per dimension. |
|
|
206
|
+
| `detect_stuck_agent` | Flags an agent repeating the same tool call — the stuck-loop signature. |
|
|
207
|
+
| `build_alert_payload` | Turns any result into a Slack, ntfy, or PagerDuty webhook payload. |
|
|
208
|
+
|
|
209
|
+
Resource `scorchmark://pricing/current` exposes the curated cross-provider pricing model.
|
|
210
|
+
|
|
211
|
+
## Log format
|
|
212
|
+
|
|
213
|
+
One JSON object per line — the de-facto schema the cost trackers, and Claude's own usage fields,
|
|
214
|
+
already emit:
|
|
215
|
+
|
|
216
|
+
```json
|
|
217
|
+
{"request_id": "r1", "ts": "2026-06-21T03:00:00Z", "provider": "anthropic",
|
|
218
|
+
"model": "claude-opus-4-8", "agent_id": "pr-loop", "input_tokens": 2000,
|
|
219
|
+
"output_tokens": 1500, "cache_write_tokens": 800000, "cache_read_tokens": 0}
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
`ts` accepts ISO-8601 (naive timestamps are read as UTC), epoch seconds, or epoch milliseconds.
|
|
223
|
+
`cost_usd` is optional and computed when absent. Anthropic's native `cache_creation_input_tokens`
|
|
224
|
+
and `cache_read_input_tokens` are accepted too. Two optional field groups unlock extra tools:
|
|
225
|
+
|
|
226
|
+
| Field group | Unlocks |
|
|
227
|
+
|---|---|
|
|
228
|
+
| `rate_limit_remaining_tokens`, `rate_limit_limit_tokens`, `rate_limit_reset_s` (and `*_requests`) | `predict_rate_limit` |
|
|
229
|
+
| `tool_name`, `tool_args_hash` | `detect_stuck_agent` |
|
|
230
|
+
|
|
231
|
+
## Alerting
|
|
232
|
+
|
|
233
|
+
Set `SCORCHMARK_WEBHOOK_URL` to a JSON webhook (Slack, ntfy, PagerDuty), then call
|
|
234
|
+
`check_budget(..., alert=True)` to POST a payload on `warn` or `breach`. Or call
|
|
235
|
+
`build_alert_payload(result)` on any tool's output and route it yourself.
|
|
236
|
+
|
|
237
|
+
The webhook URL is yours to supply; if you self-host this for others, validate/allowlist it (an
|
|
238
|
+
attacker-controlled URL is an SSRF vector).
|
|
239
|
+
|
|
240
|
+
## Pricing
|
|
241
|
+
|
|
242
|
+
| Tier | Price | For |
|
|
243
|
+
|---|---|---|
|
|
244
|
+
| Free | $0 | find the cache tax on your own logs — the solo dev who got burned once |
|
|
245
|
+
| Pro | $19/mo | unattended loops: cache-waste + burn-acceleration early warning, webhook alerting |
|
|
246
|
+
| Team | $49/mo | per-agent attribution, model-swap savings simulator, pricing-drift, audit-trail export |
|
|
247
|
+
|
|
248
|
+
Catch one runaway loop and it has paid for itself many times over — and the free tier alone catches
|
|
249
|
+
the $6k cache-TTL pattern.
|
|
250
|
+
|
|
251
|
+
**Unlocking Pro/Team.** The paid tools (`detect_spend_acceleration`, `cost_by_agent`,
|
|
252
|
+
`simulate_model_swap`, `detect_pricing_drift`, and webhook alerting) unlock with a signed license
|
|
253
|
+
key, verified **offline** (Ed25519 — no phone-home, so the no-outbound-calls guarantee holds):
|
|
254
|
+
|
|
255
|
+
```bash
|
|
256
|
+
pip install 'scorchmark[pro]' # adds the offline verifier
|
|
257
|
+
export SCORCHMARK_LICENSE=SCM1..... # the key from your purchase
|
|
258
|
+
scorchmark license # confirm → tier: TEAM · active
|
|
259
|
+
```
|
|
260
|
+
|
|
261
|
+
Buy via MCPize (managed billing) or direct Stripe — the full get-paid setup is in
|
|
262
|
+
[PAYMENTS.md](PAYMENTS.md). The free tier needs none of this and stays pure-stdlib.
|
|
263
|
+
|
|
264
|
+
## Security
|
|
265
|
+
|
|
266
|
+
Read-only, local-only, no credential storage, no outbound calls from core logic. Core modules have
|
|
267
|
+
zero runtime dependencies beyond the Python standard library. See [SECURITY.md](SECURITY.md).
|
|
268
|
+
|
|
269
|
+
## Cross-provider cache economics
|
|
270
|
+
|
|
271
|
+
The three providers price caching three different ways, and `detect_cache_waste` models each —
|
|
272
|
+
this is why a generic "cache miss" tool gets the dollars wrong.
|
|
273
|
+
|
|
274
|
+
| Provider | Cache model | Where the waste is | Same slow loop* |
|
|
275
|
+
|---|---|---|---|
|
|
276
|
+
| Anthropic | Write **premium** (write = 1.25× input, read = 0.1×) | Re-paying the write premium when the loop interval exceeds the TTL | **$237** |
|
|
277
|
+
| OpenAI | Automatic, **no write premium** (read = 0.1× input) | A stable prefix that never cache-hits, losing the ~90% read discount | $46 (gpt-5) |
|
|
278
|
+
| Google Gemini | Read discount **plus hourly storage** ($4.50/M-tok/hr Pro) | Missed discount, and storage billed on idle explicit caches | $46 (2.5-pro) |
|
|
279
|
+
|
|
280
|
+
*Same 46-wake-up, 800k-context, 30-min loop, priced per provider. The catastrophic version is
|
|
281
|
+
Anthropic-specific — the write premium is what turned that loop into a $6k bill. On OpenAI/Gemini the
|
|
282
|
+
identical loop "only" forfeits the read discount, which the detector reports honestly as a smaller number.
|
|
283
|
+
|
|
284
|
+
## Accuracy
|
|
285
|
+
|
|
286
|
+
Anthropic, OpenAI, and Google rates in `pricing.py` were re-verified on 2026-06-22 against each
|
|
287
|
+
provider's official pricing page (platform.claude.com, developers.openai.com/api/docs/pricing,
|
|
288
|
+
ai.google.dev/gemini-api/docs/pricing) — every row confirmed, and the current OpenAI tiers
|
|
289
|
+
(incl. `gpt-5.4-mini` / `-nano`) added. The tables are the standard context tier; very-large-context
|
|
290
|
+
pricing (OpenAI >272K, Gemini >200K) and Gemini's hourly cache-*storage* fee are noted but not priced
|
|
291
|
+
per row, since the cost log carries no context-tier or cache-lifetime field. `detect_pricing_drift`
|
|
292
|
+
exists because providers change rates without notice — run it regularly.
|
|
293
|
+
|
|
294
|
+
## License
|
|
295
|
+
|
|
296
|
+
**Code: MIT** (see [LICENSE](LICENSE)) — the entire source, including the gated tools, is free
|
|
297
|
+
to read, fork, and modify. This is honest open-core, not DRM.
|
|
298
|
+
|
|
299
|
+
**Pro/Team license keys** are a separate commercial purchase: a signed key (verified offline,
|
|
300
|
+
Ed25519) that activates the paid tools in official builds and funds the maintained, cross-provider
|
|
301
|
+
pricing model. Buying a key supports the project and gets you the official tier — the MIT license
|
|
302
|
+
means you *could* edit the gate out, but the key is what keeps the pricing data and the audit-trail
|
|
303
|
+
tier maintained. Keys are per-purchaser and non-transferable; sold with no warranty (the MIT terms
|
|
304
|
+
govern the software itself). Buy via MCPize (managed billing) or direct Stripe — see
|
|
305
|
+
[PAYMENTS.md](PAYMENTS.md).
|