@@ -1064,7 +1064,7 @@ const EnvironmentSchema = z
10641064 // off onto a dedicated worker service. Unset → inherits
10651065 // TRIGGER_MOLLIFIER_ENABLED, so single-container self-hosters don't have to
10661066 // flip two switches. Multi-replica drainers are correct — `popAndMarkDraining`
1067- // is an atomic ZPOPMIN + status flip in one Lua call, so only one replica
1067+ // is an atomic RPOP + status flip in one Lua call, so only one replica
10681068 // can win any given entry — but inefficient: polling load (SMEMBERS +
10691069 // per-env scans) multiplies by N, and `TRIGGER_MOLLIFIER_DRAIN_CONCURRENCY`
10701070 // is per-process so engine load also multiplies. Splitting the drainer
@@ -1137,6 +1137,78 @@ const EnvironmentSchema = z
11371137 . int ( )
11381138 . positive ( )
11391139 . default ( 5 * 60_000 ) ,
1140+ // Bounds for one stale-sweep pass (see mollifierStaleSweep.server.ts).
1141+ // Max entries scanned per env and max orgs visited per tick — together
1142+ // they cap the Redis traffic / wall-time of a single sweep pass.
1143+ TRIGGER_MOLLIFIER_STALE_SWEEP_MAX_ENTRIES_PER_ENV : z . coerce
1144+ . number ( )
1145+ . int ( )
1146+ . positive ( )
1147+ . default ( 1000 ) ,
1148+ TRIGGER_MOLLIFIER_STALE_SWEEP_MAX_ORGS_PER_PASS : z . coerce
1149+ . number ( )
1150+ . int ( )
1151+ . positive ( )
1152+ . default ( 100 ) ,
1153+
1154+ // --- Mollifier buffer internals (wired into MollifierBuffer in
1155+ // mollifierBuffer.server.ts). ---
1156+ // Grace TTL applied to the entry hash on drainer ack so direct reads
1157+ // (retrieve, trace) have a safety net while PG replica lag settles.
1158+ TRIGGER_MOLLIFIER_ACK_GRACE_TTL_SECONDS : z . coerce . number ( ) . int ( ) . positive ( ) . default ( 30 ) ,
1159+ // ioredis per-request retry limit on the buffer's Redis client.
1160+ TRIGGER_MOLLIFIER_REDIS_MAX_RETRIES_PER_REQUEST : z . coerce
1161+ . number ( )
1162+ . int ( )
1163+ . positive ( )
1164+ . default ( 20 ) ,
1165+ // ioredis reconnect backoff envelope for the buffer client: the base
1166+ // grows by `STEP_MS` per attempt, capped at `MAX_MS`, then equal-jittered.
1167+ TRIGGER_MOLLIFIER_REDIS_RECONNECT_STEP_MS : z . coerce . number ( ) . int ( ) . positive ( ) . default ( 50 ) ,
1168+ TRIGGER_MOLLIFIER_REDIS_RECONNECT_MAX_MS : z . coerce . number ( ) . int ( ) . positive ( ) . default ( 1000 ) ,
1169+
1170+ // --- Mollifier drainer loop internals (wired into MollifierDrainer in
1171+ // mollifierDrainer.server.ts). ---
1172+ // Tick gap when a tick drained nothing; under backlog ticks run back-to-back.
1173+ TRIGGER_MOLLIFIER_DRAIN_POLL_INTERVAL_MS : z . coerce . number ( ) . int ( ) . positive ( ) . default ( 100 ) ,
1174+ // Cap on the drainer's exponential backoff after consecutive runOnce errors.
1175+ TRIGGER_MOLLIFIER_DRAIN_MAX_BACKOFF_MS : z . coerce . number ( ) . int ( ) . positive ( ) . default ( 5_000 ) ,
1176+ // Floor for the drainer's backoff base (so a tiny poll interval doesn't
1177+ // collapse the backoff to near-zero during a sustained outage).
1178+ TRIGGER_MOLLIFIER_DRAIN_BACKOFF_FLOOR_MS : z . coerce . number ( ) . int ( ) . positive ( ) . default ( 100 ) ,
1179+ // Required margin between the drainer's shutdown deadline and
1180+ // GRACEFUL_SHUTDOWN_TIMEOUT; boot fails loud if the timeout leaves less.
1181+ TRIGGER_MOLLIFIER_DRAIN_SHUTDOWN_MARGIN_MS : z . coerce . number ( ) . int ( ) . positive ( ) . default ( 1_000 ) ,
1182+
1183+ // How often the draining-tracker ZSET cardinality is polled into the gauge.
1184+ TRIGGER_MOLLIFIER_DRAINING_GAUGE_INTERVAL_MS : z . coerce
1185+ . number ( )
1186+ . int ( )
1187+ . positive ( )
1188+ . default ( 15_000 ) ,
1189+
1190+ // --- Pre-gate idempotency claim (idempotencyClaim.server.ts). ---
1191+ // TTL on the claim key (and the upper clamp on the customer-derived
1192+ // claim TTL), how long a waiter blocks before timing out, and the
1193+ // waiter poll interval.
1194+ TRIGGER_MOLLIFIER_CLAIM_TTL_SECONDS : z . coerce . number ( ) . int ( ) . positive ( ) . default ( 30 ) ,
1195+ TRIGGER_MOLLIFIER_CLAIM_WAIT_MS : z . coerce . number ( ) . int ( ) . positive ( ) . default ( 5_000 ) ,
1196+ TRIGGER_MOLLIFIER_CLAIM_POLL_MS : z . coerce . number ( ) . int ( ) . positive ( ) . default ( 25 ) ,
1197+
1198+ // --- Buffered-run mutate-with-fallback wait loop (mutateWithFallback.server.ts). ---
1199+ // Ceiling on the wait-for-materialisation loop, initial poll gap, the
1200+ // backoff ceiling, and the exponential growth factor (a float).
1201+ TRIGGER_MOLLIFIER_MUTATE_SAFETY_NET_MS : z . coerce . number ( ) . int ( ) . positive ( ) . default ( 2_000 ) ,
1202+ TRIGGER_MOLLIFIER_MUTATE_POLL_STEP_MS : z . coerce . number ( ) . int ( ) . positive ( ) . default ( 20 ) ,
1203+ TRIGGER_MOLLIFIER_MUTATE_MAX_POLL_STEP_MS : z . coerce . number ( ) . int ( ) . positive ( ) . default ( 250 ) ,
1204+ TRIGGER_MOLLIFIER_MUTATE_BACKOFF_FACTOR : z . coerce . number ( ) . positive ( ) . default ( 1.7 ) ,
1205+
1206+ // --- Buffered-run metadata CAS retry loop (applyMetadataMutation.server.ts). ---
1207+ // Retry budget for concurrent metadata writers, and the jittered
1208+ // conflict-backoff envelope: random in [0, base + attempt * step) ms.
1209+ TRIGGER_MOLLIFIER_METADATA_MAX_RETRIES : z . coerce . number ( ) . int ( ) . positive ( ) . default ( 12 ) ,
1210+ TRIGGER_MOLLIFIER_METADATA_BACKOFF_BASE_MS : z . coerce . number ( ) . int ( ) . positive ( ) . default ( 5 ) ,
1211+ TRIGGER_MOLLIFIER_METADATA_BACKOFF_STEP_MS : z . coerce . number ( ) . int ( ) . positive ( ) . default ( 5 ) ,
11401212
11411213 BATCH_TRIGGER_PROCESS_JOB_VISIBILITY_TIMEOUT_MS : z . coerce
11421214 . number ( )
0 commit comments