- Server no longer mirrors app.Runtime services (gov/svc/pwSvc/...): 574 call sites now use accessors in runtime_accessors.go - backgroundLoop (mutex+sync.Once) stops sweeper/publisher/reminder/wsGC goroutines race-free (baseline44161d2areproduced DATA RACE; now green under -race) - goose 00071 duplicate (dialogue merge1da17a28brought two 00071): context-conflict-adjudications renumbered to 00072; dev DB applied only through 00070 so zero data migration - task_finalize tests build minimal app.Runtime; test injection via serverTestOverrides + setOverride* (explicit-nil markers for fail-closed cases)
28 lines
818 B
Go
28 lines
818 B
Go
package server
|
|
|
|
import (
|
|
"strings"
|
|
)
|
|
|
|
// callerOwnsSquadLease reports whether holderID (typically a task run_id) belongs to userID.
|
|
// When AllowInMemory is set and the run is not registered yet (common in HTTP unit harnesses
|
|
// that acquire a squad lease without CreateAndStart), ownership is treated as the caller's
|
|
// responsibility — production keeps AllowInMemory=false so missing runs stay denied.
|
|
func (s *Server) callerOwnsSquadLease(userID int64, holderID string) bool {
|
|
holderID = strings.TrimSpace(holderID)
|
|
if userID <= 0 || holderID == "" {
|
|
return false
|
|
}
|
|
if s == nil || s.taskRuns() == nil {
|
|
return false
|
|
}
|
|
run, err := s.taskRuns().GetRun(holderID)
|
|
if err != nil || run == nil {
|
|
if s.cfg != nil && s.cfg.AllowInMemory {
|
|
return true
|
|
}
|
|
return false
|
|
}
|
|
return run.UserID == userID
|
|
}
|