feat: add review effort accounting and budget governor
This commit is contained in:
@@ -429,6 +429,41 @@ def test_parse_repo_config_static_message_ignores_blank():
|
||||
assert "static_message" not in parse_repo_config(json.dumps({"static_message": 42}))
|
||||
|
||||
|
||||
def test_parse_repo_config_sanitizes_budget_limits():
|
||||
cfg = parse_repo_config(json.dumps({
|
||||
"budget": {
|
||||
"max_steps": "20",
|
||||
"max_total_tokens": 120000,
|
||||
"max_output_tokens": 20000,
|
||||
"max_duration_seconds": 480,
|
||||
"max_lenses": 4,
|
||||
"max_equivalent_cost_usd": "1.25",
|
||||
"unknown": 99,
|
||||
}
|
||||
}))
|
||||
assert cfg["budget"] == {
|
||||
"max_steps": 20,
|
||||
"max_total_tokens": 120000,
|
||||
"max_output_tokens": 20000,
|
||||
"max_duration_seconds": 480,
|
||||
"max_lenses": 4,
|
||||
"max_equivalent_cost_usd": 1.25,
|
||||
}
|
||||
|
||||
|
||||
def test_parse_repo_config_drops_invalid_budget_values():
|
||||
cfg = parse_repo_config(json.dumps({
|
||||
"budget": {
|
||||
"max_steps": 0,
|
||||
"max_total_tokens": 999999999,
|
||||
"max_duration_seconds": -1,
|
||||
"max_lenses": 99,
|
||||
"max_equivalent_cost_usd": 0,
|
||||
}
|
||||
}))
|
||||
assert "budget" not in cfg
|
||||
|
||||
|
||||
def test_parse_repo_config_reads_model_override():
|
||||
# Per-repo override is validated against cost_model.PRICES. Only keys
|
||||
# the cost model knows about can override the review engine.
|
||||
@@ -2148,4 +2183,3 @@ def test_format_review_body_confidence_clamps_out_of_range():
|
||||
assert "Merge confidence: 5/5 🟢" in body_hi
|
||||
body_lo = format_review_body("- x", "glm-5.2:cloud", "abcdef1234567890", confidence=0)
|
||||
assert "Merge confidence: 1/5 🔴" in body_lo
|
||||
|
||||
|
||||
Reference in New Issue
Block a user