feat: add deployable alpha silo

This commit is contained in:
2026-07-11 00:25:45 +08:00
parent 44557da499
commit 9e954790dc
57 changed files with 2792 additions and 400 deletions
+12
View File
@@ -0,0 +1,12 @@
import { describe, expect, it } from "vitest";
import { SiloFixedWindowRateLimiter } from "../../src/deployment/siloRateLimit.js";
describe("Silo fixed-window rate limiter", () => {
it("returns an explicit retry interval and resets at the next window", () => {
const limiter = new SiloFixedWindowRateLimiter(2, 60_000, 1_000);
expect(limiter.consume(1_000)).toEqual({ allowed: true });
expect(limiter.consume(2_000)).toEqual({ allowed: true });
expect(limiter.consume(3_000)).toEqual({ allowed: false, retryAfterSeconds: 58 });
expect(limiter.consume(61_000)).toEqual({ allowed: true });
});
});