commit 4663c3160e50cada0cab3e111e9dc2398dea3e6f
parent bfcfb20c27bb22b2b05e16af1ed98cafec8cfc27
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date: Thu, 15 Oct 2026 16:27:13 -0400
Merge r29/pace-floor: a platform's adaptive pace eases back to its base (Odysee no longer left at --sleep-requests 1e-66)
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Diffstat:
2 files changed, 59 insertions(+), 4 deletions(-)
diff --git a/common/jobs/platformBackoff.test.ts b/common/jobs/platformBackoff.test.ts
@@ -22,6 +22,12 @@ import {
FAILS_TO_REACH_CAP,
heldPlatformSentence,
prunePlatformPacing,
+ coercePlatformPace,
+ decayPaceByTime,
+ effectivePaceSeconds,
+ escalatePlatform,
+ PACE_TIME_DECAY_MS,
+ settlePlatformClean,
} from "./platformBackoff";
import { sanitizePacing } from "../lib/settingsSchema";
@@ -263,3 +269,31 @@ test("the held sentence names the hold and the next probe", () => {
"Auto-download probes it once every 60 min — the next probe is in 42 min. Sync will run once a probe comes back clean.",
);
});
+
+test("a base-0 pace (Odysee) eases back to the base, not toward 0 forever", () => {
+ const state = { platformBackoff: {}, platformPace: {}, platformHolds: {} } as Parameters<typeof escalatePlatform>[0];
+ escalatePlatform(state, "odysee", "rate_limit", 0, { baseSeconds: 0, rand: noJitter });
+ assert.equal(state.platformPace.odysee.sleepRequestsSeconds, 1);
+ // Clean units: 1 s halves to 0.5 s, under the smallest raised pace → the base, entry gone.
+ for (let i = 0; i < PACING_DEFAULTS.decayAfterCleanUnits; i++) {
+ settlePlatformClean(state, "odysee", { baseSeconds: 0 });
+ }
+ assert.equal(state.platformPace.odysee, undefined);
+
+ // The hourly easing: 4 s, a day later, is the base (never 4/2^24).
+ const entry = { sleepRequestsSeconds: 4, baseSeconds: 0, cleanUnits: 0, steppedAt: 0 };
+ assert.equal(effectivePaceSeconds(entry, 24 * PACE_TIME_DECAY_MS), 0);
+ assert.equal(effectivePaceSeconds(entry, 1 * PACE_TIME_DECAY_MS), 2);
+ const pace = { odysee: entry };
+ decayPaceByTime(pace, 24 * PACE_TIME_DECAY_MS);
+ assert.deepEqual(pace, {});
+});
+
+test("a stored sub-second pace from before the floor reads as the base", () => {
+ const out = coercePlatformPace({
+ odysee: { sleepRequestsSeconds: 1.1869459682199748e-66, baseSeconds: 0, cleanUnits: 0, steppedAt: 1 },
+ rumble: { sleepRequestsSeconds: 2, baseSeconds: 1, cleanUnits: 0, steppedAt: 1 },
+ youtube: { sleepRequestsSeconds: 1, baseSeconds: 1, cleanUnits: 0, steppedAt: 1 },
+ });
+ assert.deepEqual(Object.keys(out), ["rumble"]);
+});
diff --git a/common/jobs/platformBackoff.ts b/common/jobs/platformBackoff.ts
@@ -426,7 +426,7 @@ export function settlePlatformClean(
pace.cleanUnits += 1;
if (pace.cleanUnits >= Math.max(1, pacing.decayAfterCleanUnits)) {
decayed = true;
- const next = pace.sleepRequestsSeconds / 2;
+ const next = halvePace(pace.sleepRequestsSeconds, pace.baseSeconds);
if (next <= pace.baseSeconds) delete state.platformPace[platform];
else
state.platformPace[platform] = {
@@ -465,10 +465,24 @@ export function prunePlatformPacing(state: PlatformPacingState, now: number): vo
export function effectivePaceSeconds(entry: PlatformPaceEntry, now: number): number {
const steps = Math.max(0, Math.floor((now - entry.steppedAt) / PACE_TIME_DECAY_MS));
let v = entry.sleepRequestsSeconds;
- for (let i = 0; i < steps && v > entry.baseSeconds; i++) v = v / 2;
+ for (let i = 0; i < steps && v > entry.baseSeconds; i++) v = halvePace(v, entry.baseSeconds);
return Math.max(v, entry.baseSeconds);
}
+// The smallest RAISED pace: a rate limit doubles to at least this
+// (escalatePlatform's `Math.max(1, …)`), so a halving that falls below it is
+// back at the base. Without it a platform whose base is 0 (Odysee) halved
+// toward 0 forever: its entry was never deleted and every spawn was passed
+// `--sleep-requests 1e-66`.
+export const MIN_RAISED_PACE_SECONDS = 1;
+
+// One easing step: half the pace, or the base once that is below the base or
+// below the smallest raised pace.
+export function halvePace(seconds: number, baseSeconds: number): number {
+ const next = seconds / 2;
+ return next <= baseSeconds || next < MIN_RAISED_PACE_SECONDS ? baseSeconds : next;
+}
+
// Apply the hourly easing to the stored map (an entry at its base is
// deleted). Mutates. Called where the state is pruned and on every unit.
export function decayPaceByTime(pace: PlatformPaceState, now: number): void {
@@ -547,10 +561,17 @@ export function coercePlatformPace(value: unknown): PlatformPaceState {
for (const [pf, raw] of Object.entries(value as Record<string, unknown>)) {
if (!raw || typeof raw !== "object") continue;
const r = raw as Record<string, unknown>;
- if (finite(r.sleepRequestsSeconds) && r.sleepRequestsSeconds > 0) {
+ const base = finite(r.baseSeconds) && r.baseSeconds >= 0 ? r.baseSeconds : 0;
+ // An entry at or under its base, or under the smallest raised pace (one
+ // written before halvePace), is a platform at its base: no entry.
+ if (
+ finite(r.sleepRequestsSeconds) &&
+ r.sleepRequestsSeconds > base &&
+ r.sleepRequestsSeconds >= MIN_RAISED_PACE_SECONDS
+ ) {
out[pf] = {
sleepRequestsSeconds: r.sleepRequestsSeconds,
- baseSeconds: finite(r.baseSeconds) && r.baseSeconds >= 0 ? r.baseSeconds : 0,
+ baseSeconds: base,
cleanUnits: finite(r.cleanUnits) && r.cleanUnits >= 0 ? Math.floor(r.cleanUnits) : 0,
steppedAt: finite(r.steppedAt) ? r.steppedAt : 0,
};