From 6acddd3e82b698f9edbdf5b2e7460d2a7a662434 Mon Sep 17 00:00:00 2001 From: Heimdall Date: Wed, 11 Nov 2026 11:06:52 +0000 Subject: [PATCH] Mouth: pin the read-window boundary (99 and 100 raw events) and its homeserver assumption Co-Authored-By: Claude Sonnet 5.5 --- docs/bridge.md | 2 +- tests/persona-matrix-mouth.test.mjs | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/docs/bridge.md b/docs/bridge.md index a338dd1..e899b6c 100644 --- a/docs/bridge.md +++ b/docs/bridge.md @@ -242,7 +242,7 @@ The tail is **data, not instruction**. A line is what a sender typed in a room, |---|---| | The room's read failed (the homeserver refused or errored) or did not answer within 10 seconds (`sendTimeoutMs`); the room is logged and contributes no lines | the mouth | | The room had more than 20 lines outside threads (the per-room cap; her own lines count), so older ones were left out | the mouth | -| The read window came back full (100 raw events, before edits and thread replies are set aside), so real lines older than the window may exist and are unseen; a shorter chunk means the room's history was exhausted. A room whose history is exactly 100 events long is gapped too, since the mouth cannot tell | the mouth | +| The read window came back full (100 raw events, before edits and thread replies are set aside), so real lines older than the window may exist and are unseen; a shorter chunk means the room's history was exhausted. A room whose history is exactly 100 events long is gapped too, since the mouth cannot tell. The rule assumes a homeserver returns the 100 events asked for whenever older history exists; a server that caps the limit lower turns a truncated read into a false "whole", and Bifrost does not detect that | the mouth | | One of the room's lines was cut by the 60-line total cap (only the newest 60 over all rooms are kept) | the mouth | | A line was dropped as malformed (no event id) | the mouth | | The reply byte budget (256 KiB, deliveries first) cut the room's oldest lines, or a line would not encode and was skipped | the reply | diff --git a/tests/persona-matrix-mouth.test.mjs b/tests/persona-matrix-mouth.test.mjs index 8d9b30f..b2ed814 100644 --- a/tests/persona-matrix-mouth.test.mjs +++ b/tests/persona-matrix-mouth.test.mjs @@ -1679,6 +1679,10 @@ test("tail gaps: a full read window hides older real lines behind edits and thre const whole = await tailed({ preload: { [ROOM]: [...lines(ROOM, 5), ...noise(60, 0)] } }); assert.equal(whole.tail.length, 5); assert.deepEqual(whole.gaps, [], "a chunk shorter than the window reached the room's start"); + const at99 = await tailed({ preload: { [ROOM]: [...lines(ROOM, 5), ...noise(94, 0)] } }); + assert.deepEqual(at99.gaps, [], "99 raw events: one short of the window, history exhausted"); + const at100 = await tailed({ preload: { [ROOM]: [...lines(ROOM, 5), ...noise(95, 0)] } }); + assert.deepEqual(at100.gaps, [SWARM_ALIAS], "exactly 100 raw events fill the window, so older history cannot be ruled out"); }); test("tail gaps: the total cap boundary: exactly 60 lines over all rooms is no gap, a 61st names the room that lost its oldest line", async () => {