Make English the repository working language (#5)

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Yaowei ZhengandClaude Fable 5 authored and GitHub committed 2026-07-20 17:45:02 +08:00
1 parent e80cde0ea6
commit 0eaaa54e25
136 files changed
+1515 -1352

No files matched your search

+11 -11
View File
@@ -13,7 +13,7 @@ function foreignEpoch(ch: Channel): string {
}
describe("channel", () => {
it("publish 分配 `<epoch>-<seq>` 单调 id 并广播", () => {
it("publish assigns monotonic `<epoch>-<seq>` ids and broadcasts", () => {
const ch = new Channel();
const seen: ChannelEvent[] = [];
ch.subscribe((e) => seen.push(e));
@@ -26,7 +26,7 @@ describe("channel", () => {
expect(JSON.parse(seen[0]!.data)).toEqual({ a: 1 });
});
it("退订后不再接收", () => {
it("no longer receives after unsubscribe", () => {
const ch = new Channel();
const seen: ChannelEvent[] = [];
const unsub = ch.subscribe((e) => seen.push(e));
@@ -36,7 +36,7 @@ describe("channel", () => {
expect(seen).toHaveLength(1);
});
it("按条数上限淘汰最旧事件", () => {
it("evicts the oldest events by the count cap", () => {
const ch = new Channel({ maxBufferCount: 3 });
for (let i = 0; i < 5; i++) ch.publish(`m${i}`); // seq 1..5, buffer retains 3, 4, 5
const miss = ch.replayAfter(`${ch.epoch}-1`); // event 2 has been evicted
@@ -46,7 +46,7 @@ describe("channel", () => {
expect(hit.events.map((e) => e.id)).toEqual([`${ch.epoch}-4`, `${ch.epoch}-5`]);
});
it("按字节上限淘汰最旧事件", () => {
it("evicts the oldest events by the byte cap", () => {
const ch = new Channel({ maxBufferBytes: 30 });
ch.publish("a".repeat(20));
ch.publish("b".repeat(20)); // event 1 was evicted due to the byte cap
@@ -56,7 +56,7 @@ describe("channel", () => {
expect(hit.events.map((e) => e.id)).toEqual([`${ch.epoch}-2`]);
});
it("Last-Event-ID 等于最新 id → 命中且无补发;超过已分配 seq → miss", () => {
it("Last-Event-ID at the latest id → hit, no replay; beyond the allocated seq → miss", () => {
const ch = new Channel();
ch.publish("x"); // seq 1
const same = ch.replayAfter(`${ch.epoch}-1`);
@@ -65,7 +65,7 @@ describe("channel", () => {
expect(ch.replayAfter(`${ch.epoch}-99`).hit).toBe(false);
});
it("跨纪元(通道回收重建 / 进程重启)一律 miss——即使 seq 落在命中区间", () => {
it("cross-epoch (channel rebuilt / process restart) always misses despite in-range seq", () => {
const ch = new Channel();
for (let i = 0; i < 5; i++) ch.publish(`m${i}`); // seq 1..5, all within the buffer
// Same seq, different epoch: the old implementation would false-hit on integer ranges; now it must miss -> resync.
@@ -73,7 +73,7 @@ describe("channel", () => {
expect(ch.replayAfter(`${ch.epoch}-2`).hit).toBe(true);
});
it("非法 Last-Event-ID(无纪元 / 非整数 seq)→ miss", () => {
it("invalid Last-Event-ID (no epoch / non-integer seq) → miss", () => {
const ch = new Channel();
ch.publish("x");
expect(ch.replayAfter("42").hit).toBe(false); // legacy pure-integer ids are also treated as unknown
@@ -82,13 +82,13 @@ describe("channel", () => {
expect(ch.replayAfter("-1").hit).toBe(false);
});
it("全新通道(无事件)带任何 Last-Event-ID → miss;`<epoch>-0` 从头命中", () => {
it("brand-new channel: any Last-Event-ID → miss; `<epoch>-0` hits from the start", () => {
const ch = new Channel();
expect(ch.replayAfter(`${ch.epoch}-5`).hit).toBe(false);
expect(ch.replayAfter(`${ch.epoch}-0`).hit).toBe(true); // 0 = from the start, hits since nothing was evicted (no events to replay)
});
it("sendTo 私发:占用 seq、不进缓冲、不广播", () => {
it("sendTo private send: consumes a seq, skips the buffer, no broadcast", () => {
const ch = new Channel();
const broadcast: ChannelEvent[] = [];
const priv: ChannelEvent[] = [];
@@ -102,7 +102,7 @@ describe("channel", () => {
expect(ch.replayAfter(`${ch.epoch}-1`).events.map((e) => e.id)).toEqual([`${ch.epoch}-2`]); // private sends bypass the buffer
});
it("hub:同 key 复用通道;空闲超时回收、有订阅者不回收", () => {
it("hub: same key reuses the channel; idle timeout reclaims, subscribers prevent it", () => {
const hub = new ChannelHub({ idleMs: 1000 });
const ch = hub.get("s1");
expect(hub.get("s1")).toBe(ch);
@@ -120,7 +120,7 @@ describe("channel", () => {
hub.dispose();
});
it("hub:isActive 谓词命中的通道不回收(运行中等待审批无 publish 也保留)", () => {
it("hub: isActive channels are kept (running awaiting approval with no publish)", () => {
const active = new Set(["busy"]);
const hub = new ChannelHub({ idleMs: 1000, isActive: (key) => active.has(key) });
const busy = hub.get("busy");