init monlet repo with stage 0-2 (docs, contract, agent MVP)

This commit is contained in:
Stanislav Rossovskii
2026-05-26 16:41:27 +04:00
commit dcea096327
42 changed files with 3183 additions and 0 deletions

View File

@@ -0,0 +1,29 @@
package client
import (
"math/rand/v2"
"time"
)
const (
BackoffMin = 1 * time.Second
BackoffMax = 30 * time.Second
)
// Delay computes exponential backoff with ±20% jitter.
// attempt starts at 1 for the first failed try.
func Delay(attempt int) time.Duration {
if attempt < 1 {
attempt = 1
}
d := BackoffMin
for i := 1; i < attempt; i++ {
d *= 2
if d >= BackoffMax {
d = BackoffMax
break
}
}
jitter := 1.0 + (rand.Float64()*0.4 - 0.2)
return time.Duration(float64(d) * jitter)
}