DEV Community

Cover image for You Can't Test Money Controls With a Free Model
Debashish Ghosal
Debashish Ghosal

Posted on AI-assisted

You Can't Test Money Controls With a Free Model

Every budget gate in my v0.2.0 field test was green. Every spend-velocity guard passed. Every tenant cap held. Every ROI flag was clean.

All of it was green-on-vacuum. The local model was priced at $0, so no run could ever breach. My "budget enforcement" was a unit test about arithmetic — it proved the math, not the gate.

When I sat down to test the cost system on HivePlane v0.2.0 — four budgets, spend-velocity guards, tenant spend caps, cost-per-completed-task, ROI flags, an attestation-bound result cache — I discovered that a zero-cost default model makes every money gate structurally untestable. This is the article I wish I'd written when I first mentioned the $0 problem in passing.

What a $0 model hides

Control What the green test "proved" What was actually true
Per-run budget Spend never exceeded the cap Spend was always $0.00 — the cap was unreachable
Spend-velocity guard No anomalous burn paused a run There was no burn — the guard had nothing to detect
Tenant spend cap No tenant was ever refused The cap was set against a denominator of zero
Cost-per-completed-task CPCT reported cleanly completed=False on every event — CPCT was always 0
ROI / expensive_low_value No agent flagged expensive No agent cost anything to flag

A zero-cost default model makes every budget, velocity, and ROI gate structurally untestable. You can write the test, it can pass, and it proves nothing about the seam where money is actually enforced.

The priced profile

The fix wasn't a code change. It was a test-design feature: an opt-in --priced profile that prices the local omlx model and drops the zero-cost prefix. Suddenly the budget gate fires at the right seam — admission, before the expensive work — instead of after the spend, where it's too late.

tip: If your budget enforcement test runs against a model that costs nothing, your test is about arithmetic, not enforcement. Price the model in your test profile, or you'll ship a budget gate that has never refused a real run.

Then the real bugs surfaced:

  • Production usage events were always completed=False, so cost-per-completed-task was always zero.
  • rollover() wiped mid-period spend at the period boundary, so a tenant that spent 80% of its cap lost the accounting at rollover.
  • Tenant caps only enforced for DAY periods — a weekly cap was decorative.
  • The local model's zero-cost prefix meant no run could ever breach, so the "tenant cap refused admission" gate had never once fired.

Each was a seam. Each was invisible until the model cost money.

The cache that outlived the certification

The deeper v0.2.0 money idea — and the one I'm most proud of — is the attestation-bound result cache. A cache hit requires a valid attestation. Re-certification invalidates the entry. The cache key includes the task input, the workload, the manifest version, the bundle hash, the config, and the model tier.

Why this matters: a cache that survives a behavior change is a silent regression you pay to repeat. The agent got worse; you re-certified; the old cached result is still served; you keep charging for an outcome the new artifact can no longer produce. Binding the cache to the attestation means a re-cert automatically evicts the stale result, and the savings you report are only ever savings against current certified behavior.

Field-test scenario S22 proves both halves: a cache hit reuses a result and shows the savings; a re-cert invalidates it. Before that binding, the cache (#547) had no attestation validation at all — a cached result outlived the certification that justified it.

What I learned

The product was fine; the test was lying. Price the model in your test profile — it's a test-design decision, not a code change — or your budget gate has never refused a real run. Enforce at admission, not after the spend. And bind your cache to your certification: a cache without attestation validation is a regression with a discount.

The v0.2.0 field test exercises showback (cost by tenant → team → workload with CPCT) and cache hit + invalidation as scenarios S21 and S22. The priced profile is what made them real. Full evidence in the field-test report; the cost/ROI subsystem is documented in the cost service design.

References

If your model costs $0 in CI, your budget gate has never refused a real run. What's the priced path in your test profile — and when did you last run it?

Top comments (8)

Collapse
 
innokentyb profile image
Kent Bodrov •

I agree with the direction, but I would frame the boundary as control independence rather than model price. A paid model can still produce a convincing wrong answer, and a free model can be useful for generating adversarial cases. The money control itself needs a deterministic or independently verified oracle, traceable inputs, explicit tolerances, and tests for refusal and partial failure. Which part of your control depends on model capability, and which part can be made model-independent?

Collapse
 
debashish_ghosal profile image
Debashish Ghosal •

Thanks — you've split it the right way, and I should have said "priced" instead of "paid." In HivePlane the money control is deliberately model-independent: the budget/velocity/tenant-cap gates are arithmetic over the reported cost, and they fire at the priced-usage report, not on anything the model "thinks." The model only generates the usage; a strong model helps you imagine adversarial cases, but the oracle is deterministic. The only reason price entered the story is that a $0 model made the arithmetic unreachable — the --priced profile prices the local omlx model so the gate can actually fire.

Collapse
 
innokentyb profile image
Kent Bodrov •

“Priced rather than paid” is the right boundary. It keeps the control deterministic while making the economic path reachable in local tests. The extra acceptance condition I would add is provenance: bind the price-table version and the exact usage report to the run, so a later pricing change cannot make the same trace produce a different verdict. Can your --priced profile replay an old run against the original tariff as well as the current one?

Collapse
 
anh_nguynvn_0478e614ba profile image
Anh Nguyễn Văn •

Việc các guardrail vượt qua bài test field test với model miễn phí thực sự là một tín hiệu báo động đỏ. Các dòng model nhỏ hoặc bản free thường có xu hướng "nịnh" prompt và tuân thủ các chỉ dẫn logic một cách máy móc, dẫn đến việc chúng bỏ qua các edge cases phức tạp về mặt tài chính hoặc kiểm soát chi tiêu. Kinh nghiệm của mình cho thấy khi thử nghiệm các logic liên quan đến tiền tệ hoặc giới hạn quota, nếu không dùng các model mạnh nhất để giả lập các hành vi phá vỡ quy tắc (adversarial testing), hệ thống sẽ luôn cho kết quả xanh mướt một cách giả tạo. Bạn đã thử dùng các model có khả năng suy luận logic cao hơn để thực hiện red-teaming cho các bộ gate này chưa?

Collapse
 
debashish_ghosal profile image
Debashish Ghosal •

Thanks — you've put your finger on the exact trap, and your framing is sharper than mine: a free model doesn't just miss edge cases, it flatters the prompt and follows instructions mechanically, so the adversarial cases never get generated. That's why the fix in the piece wasn't a stronger model — it was pricing the model in the test profile so the gate can actually fire at the admission seam.

On your question: yes, partly. I use a strong model to generate budget-breaking scenarios, but the oracle stays deterministic — the gate is arithmetic over the reported cost, not a model judgment. The rule I've landed on: use a strong model to attack, never to judge. Otherwise a convincing-but-wrong model output becomes a green test, which is the same trap in a new coat. Have you tried splitting it that way — strong model for attack generation, deterministic oracle for the verdict?

Collapse
 
konstantinogawa profile image
Isa Grabher •

the ai part was especially useful

Some comments may only be visible to logged-in visitors. Sign in to view all comments.