fix(epic3): сделать ATDD отмены чувствительным к регрессии и покрыть bounds токена в обеих revision (Story 3.4, FR-14)
- CANCEL_GRACE_MS 1200 -> 2500 (> LONG_HOLD_MS) и const-assert на этот порядок: при незавершённой отмене вызов успевает завершиться и записать исход внутри окна проверки, поэтому тест доказывает остановку, а не только «ещё не готово». - malformed/oversized/empty/object/array token теперь проверяются и в modern revision, не только в legacy (обе читают одно поле RequestMetaObject). - комментарий cancelled_response приведён к фактическому поведению: у остановленного вызова строки Invocation History нет вообще.
This commit is contained in:
1 parent
862cde8559
commit
f613250fd3
2 files changed
+53
-38
No files matched your search
@@ -41,10 +41,15 @@ const TOOL: &str = "crm_lifecycle_lead";
|
||||
const HOLD_MS: u64 = 250;
|
||||
/// A call that is still running when the client cancels it.
|
||||
const LONG_HOLD_MS: u64 = 1_500;
|
||||
/// The grace period after a cancellation: the call must not complete in it.
|
||||
const CANCEL_GRACE_MS: u64 = 1_200;
|
||||
/// The grace period after a cancellation. It must exceed [`LONG_HOLD_MS`]: a call that was *not*
|
||||
/// stopped completes its upstream request and records the outcome inside this window, so the checks
|
||||
/// after it prove that the cancellation stopped the call rather than only that it had not finished
|
||||
/// yet.
|
||||
const CANCEL_GRACE_MS: u64 = 2_500;
|
||||
/// The suite depends on that order: the constant must not silently drop back below the hold.
|
||||
const _: () = assert!(CANCEL_GRACE_MS > LONG_HOLD_MS);
|
||||
|
||||
#[derive(Clone, Copy)]
|
||||
#[derive(Clone, Copy, Debug)]
|
||||
enum Revision {
|
||||
Legacy,
|
||||
Modern,
|
||||
@@ -644,40 +649,49 @@ async fn at_3_4_02_malformed_and_oversized_tokens_disable_progress_without_chang
|
||||
let fixture = fixture("lifecycle-bad-token", HOLD_MS, 5_000).await;
|
||||
let session = initialize_session(&fixture.client, &fixture.mcp_url, &fixture.api_key).await;
|
||||
|
||||
let oversized = "x".repeat(4096);
|
||||
let oversized = json!(oversized);
|
||||
let empty = json!("");
|
||||
let object = json!({ "not": "a token" });
|
||||
let array = json!([1, 2]);
|
||||
let boolean = json!(true);
|
||||
let mut observed = Vec::new();
|
||||
for token in [empty, object, array, boolean, oversized] {
|
||||
let reply = fixture
|
||||
.call_stream(
|
||||
Revision::Legacy,
|
||||
520,
|
||||
fixture.call_params(Some(token.clone()), Revision::Legacy),
|
||||
Some(&session),
|
||||
"req-bad-token",
|
||||
)
|
||||
.await;
|
||||
observed.push((token, reply));
|
||||
}
|
||||
// Both supported revisions read the token from the same pinned `RequestMetaObject` field, so an
|
||||
// unusable token must behave identically in each of them: no progress, unchanged result.
|
||||
for revision in [Revision::Legacy, Revision::Modern] {
|
||||
let carrier = match revision {
|
||||
Revision::Legacy => Some(session.as_str()),
|
||||
Revision::Modern => None,
|
||||
};
|
||||
let tokens = [
|
||||
json!(""),
|
||||
json!({ "not": "a token" }),
|
||||
json!([1, 2]),
|
||||
json!(true),
|
||||
json!("x".repeat(4096)),
|
||||
];
|
||||
let mut observed = Vec::new();
|
||||
for token in tokens {
|
||||
let reply = fixture
|
||||
.call_stream(
|
||||
revision,
|
||||
520,
|
||||
fixture.call_params(Some(token.clone()), revision),
|
||||
carrier,
|
||||
"req-bad-token",
|
||||
)
|
||||
.await;
|
||||
observed.push((token, reply));
|
||||
}
|
||||
|
||||
for (token, reply) in observed {
|
||||
assert!(
|
||||
reply.progress_frames().is_empty(),
|
||||
"token {token} must not produce progress, got {}",
|
||||
reply.raw
|
||||
);
|
||||
let terminal = reply.terminal();
|
||||
assert_eq!(
|
||||
terminal["result"]["structuredContent"],
|
||||
json!({ "id": "lead_123" }),
|
||||
"token {token} must not change the execution result, got {terminal}"
|
||||
);
|
||||
assert_eq!(terminal["result"]["isError"], json!(false));
|
||||
assert!(terminal["error"].is_null() || terminal.get("error").is_none());
|
||||
for (token, reply) in observed {
|
||||
assert!(
|
||||
reply.progress_frames().is_empty(),
|
||||
"{revision:?}: token {token} must not produce progress, got {}",
|
||||
reply.raw
|
||||
);
|
||||
let terminal = reply.terminal();
|
||||
assert_eq!(
|
||||
terminal["result"]["structuredContent"],
|
||||
json!({ "id": "lead_123" }),
|
||||
"{revision:?}: token {token} must not change the execution result, got {terminal}"
|
||||
);
|
||||
assert_eq!(terminal["result"]["isError"], json!(false));
|
||||
assert!(terminal["error"].is_null() || terminal.get("error").is_none());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user