fix(growth): harden AI jobs and cost controls

This commit is contained in:
2026-08-21 01:48:47 +03:30
parent 86e9d7c5f9
commit a15c04cac1
13 changed files with 366 additions and 78 deletions

View File

@@ -27,11 +27,25 @@ func TestNextTehranRefreshUsesCalendarBoundary(t *testing.T) {
}
}
func TestEstimatedTokenReservationCoversTwoTurnsAndGrowsWithEvidence(t *testing.T) {
func TestEstimatedTokenReservationCoversEveryRetryAndTurn(t *testing.T) {
t.Parallel()
small := EstimatedTokenReservation([]byte("{}"))
large := EstimatedTokenReservation(make([]byte, 1000))
if small < 3200 || large <= small || large != 5200 {
if small < 4*1600 || large <= small || large != 44000 {
t.Fatalf("reservations small=%d large=%d", small, large)
}
}
func TestServiceFingerprintChangesWithDatasetAndConfiguration(t *testing.T) {
t.Parallel()
start := time.Date(2026, 8, 21, 0, 0, 0, 0, time.UTC)
service := &Service{config: ServiceConfig{Model: "model-a", PromptVersion: "prompt-a", SchemaVersion: "schema-a"}}
current := service.fingerprint(7, "T-1", "watermark-a", start)
if current == service.fingerprint(7, "T-1", "watermark-b", start) {
t.Fatal("dataset watermark did not invalidate fingerprint")
}
service.config.PromptVersion = "prompt-b"
if current == service.fingerprint(7, "T-1", "watermark-a", start) {
t.Fatal("prompt version did not invalidate fingerprint")
}
}