fix(consult): paced settle is opt-in for the consultation reply; one rejection path for HTTP bodies and stream events (T2/T3 follow-up)

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0199rbQDTsUbCVw84wc8BTFe
This commit is contained in:
Jesse_Chen
2026-09-28 09:28:37 +08:00
co-authored by Claude Fable 5.1
parent 0bc6659052
commit 891e9c62da
6 changed files with 50 additions and 40 deletions
+7 -7
View File
@@ -116,11 +116,11 @@ test("many events collapse into one flush per frame and a paced settle writes th
assert.ok(flushes.at(-1)!.answer.length < 200, "pacing is still behind the network");
// 原值: buffer.settle() 同步一帧放完剩余文字(settled: true 立即到)
// 新值: 默认 settle 按打字节奏在 STREAM_SETTLE_MAX_FRAMES 内写完,最后一帧才 settled: true;immediate 才一帧放完
// 原因: TASK-consult-first-frame-and-pacing-20260928 D3 / BUG-1075:流尾一帧全放让短回答「一下全出来」
// 新值: settle({ paced: true }) 按打字节奏在 STREAM_SETTLE_MAX_FRAMES 内写完,最后一帧才 settled: true;无参 settle() 仍一帧放完(下一条测试)
// 原因: TASK-consult-first-frame-and-pacing-20260928 D3 / BUG-1075:流尾一帧全放让短回答「一下全出来」;其他调用方(校正面的快照合并)保持旧契约
const pendingAtSettle = answer.length - flushes.at(-1)!.answer.length;
let resolved = false;
void buffer.settle().then(() => { resolved = true; });
void buffer.settle({ paced: true }).then(() => { resolved = true; });
assert.equal(flushes.at(-1)!.settled, false, "a paced settle does not flush synchronously");
let settleFrames = 0;
while (fake.scheduledFrames > 0 && settleFrames < 200) {
@@ -152,7 +152,7 @@ test("typing pace: an ordinary backlog is capped at four characters a frame, a l
assert.equal(frames, 160 / STREAM_RELEASE_MAX_CHARS, "a 160-character lump is typed out over 40 frames, not 12");
});
test("a paced settle writes 300 leftover characters within the budget; immediate, stop-style settle is one flush", () => {
test("a paced settle writes 300 leftover characters within the budget; the default settle is one flush", () => {
const fake = fakeScheduler();
const flushes: StreamFrameSnapshot<null>[] = [];
const buffer = createStreamFrameBuffer<null>({
@@ -166,7 +166,7 @@ test("a paced settle writes 300 leftover characters within the budget; immediate
const shownBefore = flushes.at(-1)!.answer.length;
assert.ok(shownBefore < 300);
void buffer.settle();
void buffer.settle({ paced: true });
let frames = 0;
while (fake.scheduledFrames > 0 && frames < 500) {
fake.tick();
@@ -187,7 +187,7 @@ test("a paced settle writes 300 leftover characters within the budget; immediate
});
immediate.setAnswer(text);
const before = flushes.length;
void immediate.settle({ immediate: true });
void immediate.settle();
assert.equal(flushes.length, before + 1);
assert.equal(flushes.at(-1)!.answer, text);
assert.equal(flushes.at(-1)!.settled, true);
@@ -205,7 +205,7 @@ test("dispose during a paced settle lets it finish, then silences the buffer", (
const text = "字".repeat(40);
buffer.setAnswer(text);
fake.tick();
void buffer.settle();
void buffer.settle({ paced: true });
buffer.dispose();
let frames = 0;
while (fake.scheduledFrames > 0 && frames < 100) {