CI / Rust Checks (pull_request) Failing after 13m41s
CI / UI Checks (pull_request) Skipped
CI / Frontend E2E (pull_request) Skipped
CI / Community Image Smoke (pull_request) Skipped
CI / Deploy (pull_request) Skipped
Community Release / release (push) Failing after 13m33s
Recovery delivery of the accumulated, TL-accepted Epic 3 work that had never been
committed to Git (stories 3.6-3.17, see the crank board). Story 3.18 is not accepted
yet and is deliberately excluded: its logging surface, its capability registration,
its oracle projections and its tests are not part of this tree.
Accepted scope
- 3.6 typed static Resource Drafts; 3.7 publication and exact binding of static
Resource Versions; 3.8 MCP discovery/read and revocation of static Resources;
- 3.9 Resource import/export in API and UI plus TLS dependency maintenance;
3.10 REST-backed Resource templates; 3.11 shared REST read runtime and the MCP
revision/capability foundation;
- 3.12 parameterised Prompt Drafts with preview; 3.13 Prompt publication and exact
version binding to Agents; 3.14 MCP prompts; 3.15 Prompt import/export;
- 3.16 composite Prompts with published Resources (dependency content scan plus
dynamic read through the accepted 3.11 runtime, admin preview and MCP prompts/get);
- 3.17 bounded MCP completion suggestions from typed published schemas and the
resources/list admission fix for bound template publications.
Accepted evidence being reused (unchanged code paths)
- 3.16 candidate: core 7, admin-api 22, registry 4, mcp-server 4, UI 6; one final
`just verify` run 1651 passed / 0 failed / 2 ignored.
- 3.17 candidate: full run 1672 passed / 0 failed / 2 ignored, QA targeted reruns and
a real MCP Inspector 2.12.0 client smoke.
Delivery engineering in this commit
- CI: one event per change (feature branches are gated by their pull request, push
runs only on main), story events run the changed packages, the full workspace suite
stays the feature/release gate; no cache/sharding without a measured runner check.
- Release: the packaged archives, checksums and SBOM are now uploaded to the Gitea
release entry of the tag instead of dying with the runner workspace.
Not included on purpose: Story 3.18 work, build caches, runtime databases, local
credentials and scratch evidence.
Refs: crank kanban t_e39d7263; baseline 1b6db09bd1.
289 lines
10 KiB
Rust
289 lines
10 KiB
Rust
//! Required `Mcp-Name`/method identity on modern requests, and the ordering rule that the name is
|
|
//! checked before an unsupported-method dispatch.
|
|
//!
|
|
//! Tests moved verbatim from `revision_matrix.rs` (Story 3.6, kanban t_987bf309); only the module
|
|
//! prefix changed.
|
|
|
|
use super::super::common::*;
|
|
use axum::http::header;
|
|
use serde_json::{Value, json};
|
|
|
|
use super::harness::{
|
|
MODERN_REVISION, endpoint, json_body, modern_headers, modern_post, modern_request_with_params,
|
|
};
|
|
/// R7: missing or mismatched `Mcp-Method` is a validation failure.
|
|
#[tokio::test]
|
|
async fn r7_modern_missing_mcp_method_is_rejected() {
|
|
let endpoint = endpoint().await;
|
|
let headers = vec![("MCP-Protocol-Version", MODERN_REVISION.to_owned())];
|
|
let message = modern_request_with_params(Some(80), "tools/list", json!({}));
|
|
|
|
let response = modern_post(&endpoint, &headers, message, None).await;
|
|
assert_eq!(response.status().as_u16(), 400);
|
|
|
|
let body = json_body(response).await;
|
|
assert_eq!(
|
|
body["id"],
|
|
json!(80),
|
|
"the request id must be preserved, got {body}"
|
|
);
|
|
assert_eq!(body["error"]["code"], json!(-32020), "got {body}");
|
|
assert!(body["result"].is_null(), "got {body}");
|
|
}
|
|
|
|
#[tokio::test]
|
|
async fn r7_modern_mismatched_mcp_method_is_rejected() {
|
|
let endpoint = endpoint().await;
|
|
let headers = modern_headers(MODERN_REVISION, "tools/list");
|
|
let message = modern_request_with_params(Some(81), "server/discover", json!({}));
|
|
|
|
let response = modern_post(&endpoint, &headers, message, None).await;
|
|
assert_eq!(response.status().as_u16(), 400);
|
|
|
|
let body = json_body(response).await;
|
|
assert_eq!(
|
|
body["id"],
|
|
json!(81),
|
|
"the request id must be preserved, got {body}"
|
|
);
|
|
assert_eq!(body["error"]["code"], json!(-32020), "got {body}");
|
|
assert!(body["result"].is_null(), "got {body}");
|
|
}
|
|
|
|
/// R9: an unknown RPC on the modern era answers `404` + `-32601` with the request id preserved.
|
|
#[tokio::test]
|
|
async fn r9_modern_unknown_rpc_is_method_not_found() {
|
|
let endpoint = endpoint().await;
|
|
let headers = modern_headers(MODERN_REVISION, "tools/unsupported_thing");
|
|
let message = modern_request_with_params(Some(90), "tools/unsupported_thing", json!({}));
|
|
|
|
let response = modern_post(&endpoint, &headers, message, Some("r9-unknown-rpc")).await;
|
|
assert_eq!(response.status().as_u16(), 404);
|
|
|
|
let body = json_body(response).await;
|
|
assert_eq!(
|
|
body["id"],
|
|
json!(90),
|
|
"the request id must be preserved, got {body}"
|
|
);
|
|
assert_eq!(body["error"]["code"], json!(-32601), "got {body}");
|
|
assert!(body["result"].is_null(), "got {body}");
|
|
}
|
|
|
|
/// Review pass 6 (P5 / matrix row 6): `Mcp-Name` is a **required** modern header for `tools/call`,
|
|
/// `resources/read` and `prompts/get` (`streamable-http.mdx` "Standard Request Headers"), and its
|
|
/// validation must happen **before** the business dispatch. Both standard Resource/Prompt requests
|
|
/// implement their handler now (stories 3.8 and 3.14), so the missing/mismatched halves assert the
|
|
/// `-32020` header diagnostic and a correctly declared name reaches the implemented handler.
|
|
async fn modern_standard_method_name_outcome(
|
|
method: &'static str,
|
|
params: Value,
|
|
declared_name: Option<&str>,
|
|
correlation: &str,
|
|
) -> (u16, String) {
|
|
let endpoint = endpoint().await;
|
|
let mut headers = modern_headers(MODERN_REVISION, method);
|
|
if let Some(name) = declared_name {
|
|
headers.push(("Mcp-Name", name.to_owned()));
|
|
}
|
|
|
|
let response = modern_post(
|
|
&endpoint,
|
|
&headers,
|
|
modern_request_with_params(Some(150), method, params),
|
|
Some(correlation),
|
|
)
|
|
.await;
|
|
let status = response.status().as_u16();
|
|
|
|
(status, response.text().await.unwrap())
|
|
}
|
|
|
|
/// The `Mcp-Name` half of the row-6 oracle: a missing or mismatched required name header is a
|
|
/// `400` + `-32020` `HeaderMismatch` that keeps the request id, the request correlation and no result.
|
|
///
|
|
/// Review pass 7 (G2): the correlation assertion was missing entirely here even though the build
|
|
/// walkthrough claimed it was present on this half; the complete envelope is now pinned for both
|
|
/// standard names.
|
|
fn assert_required_name_header_is_a_structured_mismatch(
|
|
status: u16,
|
|
raw: &str,
|
|
correlation: &str,
|
|
case: &str,
|
|
) {
|
|
assert_eq!(
|
|
status, 400,
|
|
"{case}: row 6 requires a header-validation failure for a missing/mismatched `Mcp-Name`, got {raw}"
|
|
);
|
|
let body: Value = serde_json::from_str(raw).unwrap_or_else(|error| {
|
|
panic!(
|
|
"{case}: the `Mcp-Name` diagnostic must be a JSON-RPC envelope, got {raw:?}: {error}"
|
|
)
|
|
});
|
|
|
|
assert_eq!(body["jsonrpc"], "2.0", "{case}: got {body}");
|
|
assert_eq!(
|
|
body["id"],
|
|
json!(150),
|
|
"{case}: the diagnostic must keep the request id, got {body}"
|
|
);
|
|
assert_eq!(
|
|
body["error"]["code"],
|
|
json!(-32020),
|
|
"{case}: row 6 returns `-32020` `HeaderMismatch`, got {body}"
|
|
);
|
|
assert!(
|
|
body["error"]["message"]
|
|
.as_str()
|
|
.is_some_and(|message| !message.trim().is_empty()),
|
|
"{case}: the diagnostic must carry a non-empty message, got {body}"
|
|
);
|
|
assert_eq!(
|
|
body["error"]["data"]["request_id"],
|
|
json!(correlation),
|
|
"{case}: the diagnostic must preserve the request correlation, got {body}"
|
|
);
|
|
assert!(
|
|
body.get("result").is_none(),
|
|
"{case}: a rejected request must not carry a result, got {body}"
|
|
);
|
|
}
|
|
|
|
/// Review pass 6 (P5): `resources/read` takes its `Mcp-Name` from `params.uri`. Since Story 3.8 the
|
|
/// method is implemented, so the name is validated before the Resource handler rather than before the
|
|
/// unsupported-method answer.
|
|
#[tokio::test]
|
|
async fn review6_p5_modern_resources_read_requires_mcp_name_before_resource_dispatch() {
|
|
let uri = "crank://operations/crm_create_lead";
|
|
|
|
let missing = "review6-p5-resources-missing-name";
|
|
let (status, raw) =
|
|
modern_standard_method_name_outcome("resources/read", json!({ "uri": uri }), None, missing)
|
|
.await;
|
|
assert_required_name_header_is_a_structured_mismatch(
|
|
status,
|
|
&raw,
|
|
missing,
|
|
"resources/read missing name",
|
|
);
|
|
|
|
let mismatched = "review6-p5-resources-mismatched-name";
|
|
let (status, raw) = modern_standard_method_name_outcome(
|
|
"resources/read",
|
|
json!({ "uri": uri }),
|
|
Some("crank://operations/other"),
|
|
mismatched,
|
|
)
|
|
.await;
|
|
assert_required_name_header_is_a_structured_mismatch(
|
|
status,
|
|
&raw,
|
|
mismatched,
|
|
"resources/read mismatched name",
|
|
);
|
|
|
|
let valid = "review6-p5-resources-valid-name";
|
|
let (status, raw) = modern_standard_method_name_outcome(
|
|
"resources/read",
|
|
json!({ "uri": uri }),
|
|
Some(uri),
|
|
valid,
|
|
)
|
|
.await;
|
|
// Story 3.8: `resources/read` is an implemented capability, so a correctly declared name reaches
|
|
// the Resource handler. An unbound URI is answered by one safe, non-disclosing outcome instead of
|
|
// the era-correct unsupported-method answer.
|
|
assert_eq!(
|
|
status, 200,
|
|
"a correctly declared `Mcp-Name` must reach the Resource handler, got {raw}"
|
|
);
|
|
let body: Value = serde_json::from_str(&raw).expect("the safe answer is a JSON-RPC envelope");
|
|
assert_eq!(body["jsonrpc"], "2.0", "got {body}");
|
|
assert_eq!(
|
|
body["id"],
|
|
json!(150),
|
|
"the answer must keep the request id: {body}"
|
|
);
|
|
assert_eq!(
|
|
body["error"]["code"],
|
|
json!(-32602),
|
|
"an unbound Resource URI is safe invalid params, got {body}"
|
|
);
|
|
assert_eq!(
|
|
body["error"]["data"]["request_id"],
|
|
json!(valid),
|
|
"the safe answer must preserve the request correlation, got {body}"
|
|
);
|
|
assert!(
|
|
body.get("result").is_none(),
|
|
"a denied Resource read must not carry a result, got {body}"
|
|
);
|
|
}
|
|
|
|
/// Review pass 6 (P5): `prompts/get` takes its `Mcp-Name` from `params.name`.
|
|
#[tokio::test]
|
|
async fn review6_p5_modern_prompts_get_requires_mcp_name_before_unsupported_dispatch() {
|
|
let missing = "review6-p5-prompts-missing-name";
|
|
let (status, raw) = modern_standard_method_name_outcome(
|
|
"prompts/get",
|
|
json!({ "name": "crm_create_lead" }),
|
|
None,
|
|
missing,
|
|
)
|
|
.await;
|
|
assert_required_name_header_is_a_structured_mismatch(
|
|
status,
|
|
&raw,
|
|
missing,
|
|
"prompts/get missing name",
|
|
);
|
|
|
|
let mismatched = "review6-p5-prompts-mismatched-name";
|
|
let (status, raw) = modern_standard_method_name_outcome(
|
|
"prompts/get",
|
|
json!({ "name": "crm_create_lead" }),
|
|
Some("crm_other_lead"),
|
|
mismatched,
|
|
)
|
|
.await;
|
|
assert_required_name_header_is_a_structured_mismatch(
|
|
status,
|
|
&raw,
|
|
mismatched,
|
|
"prompts/get mismatched name",
|
|
);
|
|
|
|
let valid = "review6-p5-prompts-valid-name";
|
|
let (status, raw) = modern_standard_method_name_outcome(
|
|
"prompts/get",
|
|
json!({ "name": "crm_create_lead" }),
|
|
Some("crm_create_lead"),
|
|
valid,
|
|
)
|
|
.await;
|
|
// Story 3.14 implements the standard Prompt requests, so a correctly declared name no longer
|
|
// reaches the unsupported-method answer: it is a business answer for a Prompt that this Agent
|
|
// does not bind, and the row-6 header diagnostic is still asserted on the two halves above.
|
|
assert_eq!(
|
|
status, 200,
|
|
"a correctly declared `prompts/get` name must reach the implemented handler, got {raw}"
|
|
);
|
|
let body: Value =
|
|
serde_json::from_str(&raw).expect("the business answer is a JSON-RPC envelope");
|
|
assert_eq!(body["error"]["code"], json!(-32602), "got {body}");
|
|
assert_eq!(
|
|
body["error"]["message"],
|
|
json!("the requested prompt is not available"),
|
|
"an unbound Prompt name stays a safe business answer, got {body}"
|
|
);
|
|
assert_eq!(
|
|
body["error"]["data"]["request_id"],
|
|
json!(valid),
|
|
"the safe answer must preserve the request correlation, got {body}"
|
|
);
|
|
assert!(
|
|
body.get("result").is_none(),
|
|
"an unbound Prompt must not carry a result, got {body}"
|
|
);
|
|
}
|