feat(tenant): business-date-scope monitor lease lanes and authorization-failure cancellation
Add an optional lane filter to the monitor task lease so callers can pull a specific lane (e.g. high) and scope authorization-failure cancellation to the failing task's business date, so a challenge on one day no longer cancels queued tasks for another day. Monitor authorization-failure cancellation now requires a business date and no-ops without one. Also stop writing the nonexistent desktop_tasks.completed_at column when canceling queued tasks for an authorization failure. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -462,6 +462,7 @@ func TestLeaseNextQueuedMonitorTaskSQLUsesAccountIdentityAndClientSlots(t *testi
|
||||
"WITH current_accounts AS",
|
||||
"client_id = $3",
|
||||
"COALESCE(array_length($7::text[], 1), 0) = 0 OR dt.platform_id = ANY($7::text[])",
|
||||
"COALESCE(array_length($8::text[], 1), 0) = 0 OR dt.lane = ANY($8::text[])",
|
||||
"dt.target_account_id = target_account.desktop_id",
|
||||
"target_account.account_fingerprint",
|
||||
"target_account.platform_uid",
|
||||
@@ -502,6 +503,39 @@ func TestNormalizeDesktopTaskLeasePlatformIDs(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestNormalizeDesktopTaskLeaseLanes(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
got := normalizeDesktopTaskLeaseLanes([]string{" HIGH ", "normal", "", "high", "unsupported"})
|
||||
want := []string{"high", "normal"}
|
||||
if !reflect.DeepEqual(got, want) {
|
||||
t.Fatalf("normalizeDesktopTaskLeaseLanes() = %#v, want %#v", got, want)
|
||||
}
|
||||
if got := normalizeDesktopTaskLeaseLanes([]string{" ", "unsupported"}); got != nil {
|
||||
t.Fatalf("normalizeDesktopTaskLeaseLanes(blank) = %#v, want nil", got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestFinishQueuedDesktopTaskForAuthorizationFailureSQLMatchesDesktopTaskSchema(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
normalized := normalizeSQLForDesktopTaskTest(finishQueuedDesktopTaskForAuthorizationFailureSQL())
|
||||
if strings.Contains(normalized, "completed_at") {
|
||||
t.Fatalf("authorization cancellation query writes nonexistent desktop_tasks.completed_at: %s", normalized)
|
||||
}
|
||||
for _, fragment := range []string{
|
||||
"SET status = $2",
|
||||
"active_attempt_id = NULL",
|
||||
"lease_token_hash = NULL",
|
||||
"lease_expires_at = NULL",
|
||||
"updated_at = NOW()",
|
||||
} {
|
||||
if !strings.Contains(normalized, fragment) {
|
||||
t.Fatalf("authorization cancellation query missing %q: %s", fragment, normalized)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestLeaseQueuedDesktopTaskByIDSQLUsesAccountIdentityAndClientSlots(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user