Skip to content

Commit f67c1c0

Browse files
cliffhallclaude
andcommitted
test(everything): pin that requestState expires after its 600-second TTL
The requestState cases pinned tamper rejection and the round trip, but not expiry: that a correctly signed, untampered state is refused once its time has run out. The new case freezes the clock, continues the same state at +599 s (accepted) and at +601 s (refused with -32602), so it fails if the expiry check is absent or the TTL changes. Closes #5542 Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Signed-off-by: cliffhall <cliff@futurescale.com>
1 parent 7f383a8 commit f67c1c0

1 file changed

Lines changed: 30 additions & 1 deletion

File tree

‎src/everything/__tests__/modern.test.ts‎

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
* roots.test.ts), `requestState` carried across the multi-step tool's
1414
* rounds on both eras, with retries after missing or bad input, and the
1515
* SDK refusing an embedded request whose capability the request did not
16-
* declare (-32021) or a tampered state (-32602).
16+
* declare (-32021) or a tampered or expired state (-32602).
1717
* - Per-request log levels (`trigger-log-messages`) against the 2025-era
1818
* session level.
1919
* - Change notifications (`trigger-list-changed`, `trigger-resource-update`)
@@ -336,6 +336,35 @@ describe("multi-round-trip requests on 2026-07-28", () => {
336336
requestState: expect.any(String),
337337
});
338338
});
339+
340+
it("refuses an untampered requestState with -32602 once its 600-second TTL has passed", async () => {
341+
// Freeze the clock before the state is minted, so only the test moves it.
342+
vi.useFakeTimers({ toFake: ["Date"] });
343+
raw = await connectRaw({ elicitation: {} });
344+
const mintedAt = Date.now();
345+
const first = await raw.call("trigger-multi-step-elicitation");
346+
const answerTheName = {
347+
name: "trigger-multi-step-elicitation",
348+
arguments: {},
349+
requestState: (first as { requestState: string }).requestState,
350+
inputResponses: {
351+
name: { action: "accept", content: { name: "Ada" } },
352+
},
353+
};
354+
355+
// Inside the TTL the state is accepted, so the refusal below is the
356+
// expiry and nothing else about this continuation.
357+
vi.setSystemTime(mintedAt + 599_000);
358+
expect(await raw.result("tools/call", answerTheName)).toMatchObject({
359+
resultType: "input_required",
360+
inputRequests: { color: { method: "elicitation/create" } },
361+
});
362+
363+
// Past it, the same state is refused: only the clock has moved.
364+
vi.setSystemTime(mintedAt + 601_000);
365+
const response = await raw.request("tools/call", answerTheName);
366+
expect(response.error).toMatchObject({ code: -32602 });
367+
});
339368
});
340369

341370
describe("trigger-multi-step-elicitation", () => {

0 commit comments

Comments
 (0)