Coop: shorten first-day window — require 12h since lock, not date change

Previous guard skipped resolution if lock_date == today_date, pushing
first-day windows to 24-32h regardless of when in the UTC day the lock
fired. With per-minute lock checks, the original same-tick race no longer
exists, so the date guard was just adding latency.

New guard: at least 12h since lock. Late-night locks still get >12h
funding/voting windows; early-morning locks get 24h+ as before. No effect
on the existing run #1.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
prosolis
2026-04-28 17:50:24 -07:00
parent 5e4de7b4c3
commit 4bc541ca85

View File

@@ -148,11 +148,15 @@ func (p *AdventurePlugin) coopProcessActiveRuns() {
slog.Error("coop: load active runs", "err", err)
return
}
today := time.Now().UTC().Format("2006-01-02")
now := time.Now().UTC()
for _, run := range runs {
// Skip runs locked on this same tick — they need a full day for
// funding decisions and voting before the first floor resolves.
if run.LockedAt != nil && run.LockedAt.UTC().Format("2006-01-02") == today {
// Need at least a 12h funding window between lock and the first
// floor resolution. Without this, a run locked at 07:00 UTC would
// resolve an hour later at 08:00 UTC. With per-minute lock checks
// (locks now fire any time), the previous "same UTC date" guard
// was too conservative — it pushed first-day windows out to 24-32h
// even when 13-23h would have been plenty.
if run.LockedAt != nil && now.Sub(run.LockedAt.UTC()) < 12*time.Hour {
continue
}
if err := p.coopResolveFloor(run); err != nil {