Network policy: throttle on terminal 429 and make the sync loop / send queue defer to §5 after retry exhaustion (CR-4) #134

Closed
opened 2026-08-27 19:21:08 +02:00 by thecrealm · 0 comments
Owner

Review finding 2026-08-27 (A1). NetworkPolicy.kt:113-117 throws RateLimited(serverDelay) after maxAttempts without calling throttle(); SyncLoop.kt:109-113 then sleeps a fixed backoffOnError (5 s) and SendQueue.kt:54 a fixed retryDelay (3 s), ignoring the surfaced retryAfter. A Retry-After longer than the fixed delay is violated on the next request. The CR-4 storm test drives policy.execute directly, and FleetFairnessGateTest/EncryptedPuppetingGateTest assert politenessViolations.isEmpty() without ever enabling strictRateLimit (vacuous).

Acceptance (§5, §10.3.4, §10.5.2, CR-4, NFR-6):

  • terminal 429 records the throttle before throwing; the sync loop and send-queue requeue honour RateLimited.retryAfter (server delay always beats the fixed/computed delay) and otherwise use the §5 per-class backoff, not private timers;
  • SessionCrypto.kt:201-215 own attempt counter reviewed against the same rule;
  • a strict-429 scenario driven through a full KatrixSession (sync + send + media + /keys/query//keys/claim) and through an AppserviceFleet with strictRateLimit enabled, asserting zero politeness violations;
  • cr4_serverDelayBindsSyncLoop exercises the real SyncLoop.
Review finding 2026-08-27 (A1). `NetworkPolicy.kt:113-117` throws `RateLimited(serverDelay)` after `maxAttempts` **without** calling `throttle()`; `SyncLoop.kt:109-113` then sleeps a fixed `backoffOnError` (5 s) and `SendQueue.kt:54` a fixed `retryDelay` (3 s), ignoring the surfaced `retryAfter`. A `Retry-After` longer than the fixed delay is violated on the next request. The CR-4 storm test drives `policy.execute` directly, and `FleetFairnessGateTest`/`EncryptedPuppetingGateTest` assert `politenessViolations.isEmpty()` without ever enabling `strictRateLimit` (vacuous). Acceptance (§5, §10.3.4, §10.5.2, CR-4, NFR-6): - terminal 429 records the throttle before throwing; the sync loop and send-queue requeue honour `RateLimited.retryAfter` (server delay always beats the fixed/computed delay) and otherwise use the §5 per-class backoff, not private timers; - `SessionCrypto.kt:201-215` own attempt counter reviewed against the same rule; - a strict-429 scenario driven through a full `KatrixSession` (sync + send + media + `/keys/query`/`/keys/claim`) and through an `AppserviceFleet` with `strictRateLimit` enabled, asserting zero politeness violations; - `cr4_serverDelayBindsSyncLoop` exercises the real `SyncLoop`.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
thecrealm/katrix#134
No description provided.