Files
crank/apps/mcp-server/tests/integration/mcp_prompts/list.rs
T
bsodfather 54ce770682
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
feat(epic3): deliver the accepted Epic 3 scope through Story 3.17
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.
2026-10-25 09:08:22 +00:00

171 lines
6.0 KiB
Rust

//! AT-3.14-01 / AT-3.14-04: `prompts/list` serves exactly the bound Published Prompt Versions with
//! revision-scoped pagination and typed argument metadata; Draft, unbound and foreign Prompts of
//! another Agent are never disclosed. Every case runs on both supported protocol revisions, because
//! AC-4 requires the behaviour to be proven per revision and the legacy era resolves workspace and
//! Agent from the initialized session instead of the request body.
use serde_json::{Value, json};
use super::fixtures::*;
fn names(page: &Value) -> Vec<String> {
page["result"]["prompts"]
.as_array()
.unwrap_or_else(|| panic!("prompts/list must carry a prompts array: {page}"))
.iter()
.map(|prompt| prompt["name"].as_str().unwrap_or_default().to_owned())
.collect()
}
#[tokio::test]
async fn list_serves_only_bound_published_prompts_with_typed_arguments() {
let endpoint = prompt_endpoint().await;
for revision in [MODERN_REVISION, LEGACY_REVISION] {
let body = endpoint
.on_revision(revision, "prompts/list", json!({}), None)
.await;
assert!(
body.get("error").is_none(),
"prompts/list must succeed on {revision}: {body}"
);
let listed = names(&body);
assert_eq!(
listed, BOUND_PROMPT_NAMES,
"only the bound Published Prompt Versions may be listed on {revision}: {body}"
);
for excluded in ["draft-prompt", "other-agent-prompt"] {
assert!(
!listed.contains(&excluded.to_owned()),
"{excluded} must not be discoverable on {revision}: {body}"
);
}
let greeting = body["result"]["prompts"]
.as_array()
.unwrap()
.iter()
.find(|prompt| prompt["name"] == json!("greeting"))
.expect("the bound greeting is listed");
assert_eq!(greeting["description"], json!("Greets the customer"));
let arguments = greeting["arguments"]
.as_array()
.expect("the listed Prompt must carry argument metadata");
assert_eq!(
arguments.len(),
2,
"both arguments are advertised on {revision}: {greeting}"
);
assert_eq!(arguments[0]["name"], json!("name"));
assert_eq!(arguments[0]["required"], json!(true));
assert_eq!(arguments[0]["schema"]["type"], json!("string"));
assert_eq!(arguments[1]["name"], json!("tone"));
assert_eq!(arguments[1]["required"], json!(false));
assert_eq!(arguments[1]["schema"]["enum"], json!(["warm", "dry"]));
assert_eq!(arguments[1]["default"], json!("warm"));
assert!(
greeting.get("messages").is_none(),
"discovery must not disclose message content on {revision}: {greeting}"
);
}
}
#[tokio::test]
async fn list_paginates_deterministically_and_binds_the_cursor_to_the_revision() {
let endpoint = prompt_endpoint().await;
for revision in [MODERN_REVISION, LEGACY_REVISION] {
let first = endpoint
.on_revision(revision, "prompts/list", json!({"limit": 2}), None)
.await;
let cursor = first["result"]["nextCursor"]
.as_str()
.unwrap_or_else(|| {
panic!("a bounded first page must carry a continuation on {revision}: {first}")
})
.to_owned();
assert_eq!(
names(&first),
vec!["greeting", "review"],
"the first page is deterministic on {revision}: {first}"
);
let second = endpoint
.on_revision(
revision,
"prompts/list",
json!({"cursor": cursor.clone(), "limit": 2}),
None,
)
.await;
assert_eq!(
names(&second),
vec!["archived-prompt"],
"the continuation serves the next bound slice and nothing else on {revision}: {second}"
);
assert!(
second["result"].get("nextCursor").is_none(),
"the last page carries no continuation on {revision}: {second}"
);
// A page is never mixed across protocol revisions: the other era refuses this cursor.
let other_revision = match revision {
MODERN_REVISION => LEGACY_REVISION,
_ => MODERN_REVISION,
};
let cross_revision = endpoint
.on_revision(
other_revision,
"prompts/list",
json!({"cursor": cursor.clone()}),
None,
)
.await;
assert_eq!(
cross_revision["error"]["code"],
json!(-32602),
"a {revision} cursor must be refused as invalid params on {other_revision}: {cross_revision}"
);
// A malformed token is invalid params, never the first page.
let malformed = endpoint
.on_revision(
revision,
"prompts/list",
json!({"cursor": "not-a-cursor"}),
None,
)
.await;
assert_eq!(
malformed["error"]["code"],
json!(-32602),
"a malformed cursor is invalid params on {revision}: {malformed}"
);
}
}
#[tokio::test]
async fn list_of_an_agent_shows_only_its_own_bound_snapshot() {
let endpoint = prompt_endpoint().await;
// The other Agent binds exactly one Prompt; it must not see the sales Agent's snapshot.
let other_key = endpoint.other_agent_key().await;
for revision in [MODERN_REVISION, LEGACY_REVISION] {
let body = endpoint
.on_revision_for(
OTHER_AGENT_SLUG,
&other_key,
revision,
"prompts/list",
json!({}),
None,
)
.await;
assert_eq!(
names(&body),
vec!["other-agent-prompt"],
"an Agent sees only its own bound snapshot on {revision}: {body}"
);
}
}