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.
409 lines
15 KiB
Rust
409 lines
15 KiB
Rust
//! Story 3.17 acceptance tests: bounded completion of the arguments of bound Published Prompts and of
|
|
//! the parameters of bound Published Resource templates through MCP (AT-3.17-01..03).
|
|
//!
|
|
//! Oracles: `docs/acceptance-test-plan.md` AT-3.17-01..03, `epics.md` Story 3.17 and the pinned
|
|
//! `completion/complete` schemas of both supported revisions. Every request travels through the real
|
|
//! HTTP endpoint built by `build_test_app` against a real PostgreSQL registry; the bound versions are
|
|
//! produced through the production registry path. Each case runs on both supported revisions, because
|
|
//! AC3 requires per-revision positive/negative/authorization coverage.
|
|
//!
|
|
//! No real external MCP client is exercised here: these are local harness results against the pinned
|
|
//! wire shapes. That is stated as NOT_RUN in the story handoff instead of being claimed as a client
|
|
//! qualification.
|
|
|
|
mod fixtures;
|
|
mod response_metrics;
|
|
|
|
use serde_json::{Value, json};
|
|
|
|
use fixtures::*;
|
|
|
|
fn completion(body: &Value) -> &Value {
|
|
body.pointer("/result/completion")
|
|
.unwrap_or_else(|| panic!("the completion result is missing: {body}"))
|
|
}
|
|
|
|
fn values(body: &Value) -> Vec<String> {
|
|
completion(body)["values"]
|
|
.as_array()
|
|
.unwrap_or_else(|| panic!("`completion.values` must be an array: {body}"))
|
|
.iter()
|
|
.map(|value| {
|
|
value
|
|
.as_str()
|
|
.unwrap_or_else(|| panic!("every completion value is a string: {body}"))
|
|
.to_owned()
|
|
})
|
|
.collect()
|
|
}
|
|
|
|
fn error(body: &Value) -> (i64, String) {
|
|
let code = body
|
|
.pointer("/error/code")
|
|
.and_then(Value::as_i64)
|
|
.unwrap_or_else(|| panic!("expected a JSON-RPC error code: {body}"));
|
|
let message = body
|
|
.pointer("/error/message")
|
|
.and_then(Value::as_str)
|
|
.unwrap_or_else(|| panic!("expected a JSON-RPC error message: {body}"))
|
|
.to_owned();
|
|
(code, message)
|
|
}
|
|
|
|
fn prompt_ref(name: &str) -> Value {
|
|
json!({"type": "ref/prompt", "name": name})
|
|
}
|
|
|
|
fn resource_ref(uri: &str) -> Value {
|
|
json!({"type": "ref/resource", "uri": uri})
|
|
}
|
|
|
|
fn request(reference: Value, argument: &str, value: &str) -> Value {
|
|
json!({
|
|
"ref": reference,
|
|
"argument": {"name": argument, "value": value}
|
|
})
|
|
}
|
|
|
|
/// AT-3.17-01/03: the advertised capability equals the implemented method on both revisions.
|
|
#[tokio::test]
|
|
async fn advertisement_declares_completions_on_both_revisions() {
|
|
let endpoint = completion_endpoint().await;
|
|
|
|
let discover = endpoint.modern_method("server/discover", json!({})).await;
|
|
assert_eq!(
|
|
discover["result"]["capabilities"]["completions"],
|
|
json!({}),
|
|
"the modern advertisement must declare the completions capability: {discover}"
|
|
);
|
|
|
|
let initialize = endpoint.legacy_initialize().await;
|
|
assert_eq!(
|
|
initialize["result"]["capabilities"]["completions"],
|
|
json!({}),
|
|
"the legacy advertisement must declare the completions capability: {initialize}"
|
|
);
|
|
}
|
|
|
|
/// AT-3.17-01: bounded, authorized suggestions from the typed schema of the bound Prompt argument.
|
|
#[tokio::test]
|
|
async fn prompt_argument_completion_is_bounded_and_typed_on_every_revision() {
|
|
let endpoint = completion_endpoint().await;
|
|
|
|
for revision in [MODERN_REVISION, LEGACY_REVISION] {
|
|
let all = endpoint
|
|
.on_revision(revision, request(prompt_ref("greeting"), "tone", ""))
|
|
.await;
|
|
assert_eq!(
|
|
values(&all),
|
|
["warm", "dry"],
|
|
"the whole typed enumeration is suggested on {revision}: {all}"
|
|
);
|
|
assert_eq!(
|
|
completion(&all)["total"],
|
|
json!(2),
|
|
"the exact option count is reported on {revision}: {all}"
|
|
);
|
|
assert!(
|
|
completion(&all).get("hasMore").is_none(),
|
|
"a complete enumeration carries no `hasMore` on {revision}: {all}"
|
|
);
|
|
|
|
let filtered = endpoint
|
|
.on_revision(revision, request(prompt_ref("greeting"), "tone", "w"))
|
|
.await;
|
|
assert_eq!(
|
|
values(&filtered),
|
|
["warm"],
|
|
"the partial token filters the enumeration on {revision}: {filtered}"
|
|
);
|
|
assert_eq!(completion(&filtered)["total"], json!(1));
|
|
|
|
// Prefix matching is ASCII-case-insensitive, so a client that upper-cases a token still gets
|
|
// the published option; the value itself is served exactly as published.
|
|
let caseless = endpoint
|
|
.on_revision(revision, request(prompt_ref("greeting"), "tone", "D"))
|
|
.await;
|
|
assert_eq!(
|
|
values(&caseless),
|
|
["dry"],
|
|
"case-insensitive prefix matching on {revision}: {caseless}"
|
|
);
|
|
}
|
|
}
|
|
|
|
/// AT-3.17-01: a typed schema without an enumeration suggests nothing rather than inventing values.
|
|
#[tokio::test]
|
|
async fn an_argument_without_an_enumeration_gets_no_invented_suggestions() {
|
|
let endpoint = completion_endpoint().await;
|
|
|
|
for revision in [MODERN_REVISION, LEGACY_REVISION] {
|
|
let body = endpoint
|
|
.on_revision(revision, request(prompt_ref("greeting"), "name", "A"))
|
|
.await;
|
|
assert_eq!(
|
|
values(&body),
|
|
Vec::<String>::new(),
|
|
"a plain string argument has no enumerated suggestions on {revision}: {body}"
|
|
);
|
|
assert_eq!(completion(&body)["total"], json!(0));
|
|
assert!(completion(&body).get("hasMore").is_none());
|
|
}
|
|
}
|
|
|
|
/// AT-3.17-01/03: a Draft, unbound, foreign or unknown Prompt (and an unknown argument) is one
|
|
/// indistinguishable refusal that discloses no identifier.
|
|
#[tokio::test]
|
|
async fn a_draft_unbound_or_foreign_prompt_is_indistinguishable() {
|
|
let endpoint = completion_endpoint().await;
|
|
|
|
for revision in [MODERN_REVISION, LEGACY_REVISION] {
|
|
let mut observed = Vec::new();
|
|
for (case, request_value) in [
|
|
(
|
|
"foreign prompt",
|
|
request(prompt_ref("other-agent-prompt"), "tone", ""),
|
|
),
|
|
(
|
|
"draft prompt",
|
|
request(prompt_ref("draft-prompt"), "tone", ""),
|
|
),
|
|
(
|
|
"unbound prompt",
|
|
request(prompt_ref("unbound-prompt"), "tone", ""),
|
|
),
|
|
(
|
|
"unknown prompt",
|
|
request(prompt_ref("no-such-prompt"), "tone", ""),
|
|
),
|
|
(
|
|
"unknown argument",
|
|
request(prompt_ref("greeting"), "no-such-argument", ""),
|
|
),
|
|
] {
|
|
let body = endpoint.on_revision(revision, request_value).await;
|
|
let (code, message) = error(&body);
|
|
assert_eq!(code, -32602, "{case} on {revision}: {body}");
|
|
assert_eq!(
|
|
message, NOT_AVAILABLE,
|
|
"{case} on {revision} must use the single safe refusal: {body}"
|
|
);
|
|
assert!(
|
|
body.get("result").is_none(),
|
|
"{case} on {revision} must not carry a result: {body}"
|
|
);
|
|
let serialized = body.to_string();
|
|
for leaked in [
|
|
"other-agent-prompt",
|
|
"draft-prompt",
|
|
"unbound-prompt",
|
|
"no-such-prompt",
|
|
"no-such-argument",
|
|
"Other agent secret.",
|
|
"Draft content.",
|
|
"Unbound content.",
|
|
] {
|
|
assert!(
|
|
!serialized.contains(leaked),
|
|
"{case} on {revision} must not disclose {leaked:?}: {serialized}"
|
|
);
|
|
}
|
|
observed.push((code, message));
|
|
}
|
|
assert!(
|
|
observed.windows(2).all(|pair| pair[0] == pair[1]),
|
|
"every unavailable case must answer identically on {revision}: {observed:?}"
|
|
);
|
|
}
|
|
}
|
|
|
|
/// AT-3.17-01: the second supported reference form — a bound Resource template parameter.
|
|
#[tokio::test]
|
|
async fn resource_template_parameter_completion_uses_the_bound_schema() {
|
|
let endpoint = completion_endpoint().await;
|
|
|
|
for revision in [MODERN_REVISION, LEGACY_REVISION] {
|
|
let all = endpoint
|
|
.on_revision(
|
|
revision,
|
|
request(resource_ref(BOUND_TEMPLATE_URI), "region", ""),
|
|
)
|
|
.await;
|
|
assert_eq!(
|
|
values(&all),
|
|
["eu", "us", "apac"],
|
|
"the bound template's enumerated parameter is suggested on {revision}: {all}"
|
|
);
|
|
assert_eq!(completion(&all)["total"], json!(3));
|
|
|
|
let filtered = endpoint
|
|
.on_revision(
|
|
revision,
|
|
request(resource_ref(BOUND_TEMPLATE_URI), "region", "a"),
|
|
)
|
|
.await;
|
|
assert_eq!(
|
|
values(&filtered),
|
|
["apac"],
|
|
"the partial token filters the template parameter on {revision}: {filtered}"
|
|
);
|
|
}
|
|
}
|
|
|
|
/// AT-3.17-01/03: a foreign or unknown URI template, and an unknown parameter, share one refusal.
|
|
#[tokio::test]
|
|
async fn a_foreign_or_unknown_template_uri_is_indistinguishable() {
|
|
let endpoint = completion_endpoint().await;
|
|
|
|
for revision in [MODERN_REVISION, LEGACY_REVISION] {
|
|
let mut observed = Vec::new();
|
|
for request_value in [
|
|
request(resource_ref(FOREIGN_TEMPLATE_URI), "region", ""),
|
|
request(resource_ref("crank://no-such/{region}"), "region", ""),
|
|
request(resource_ref(BOUND_TEMPLATE_URI), "no-such-parameter", ""),
|
|
] {
|
|
let body = endpoint.on_revision(revision, request_value).await;
|
|
let (code, message) = error(&body);
|
|
assert_eq!(code, -32602, "{body}");
|
|
assert_eq!(message, NOT_AVAILABLE, "{body}");
|
|
let serialized = body.to_string();
|
|
for leaked in [
|
|
FOREIGN_TEMPLATE_URI,
|
|
"crank://no-such/{region}",
|
|
"no-such-parameter",
|
|
] {
|
|
assert!(
|
|
!serialized.contains(leaked),
|
|
"an unavailable template must not disclose {leaked:?}: {serialized}"
|
|
);
|
|
}
|
|
observed.push((code, message));
|
|
}
|
|
assert!(
|
|
observed.windows(2).all(|pair| pair[0] == pair[1]),
|
|
"every unavailable template case must answer identically on {revision}: {observed:?}"
|
|
);
|
|
}
|
|
}
|
|
|
|
/// AT-3.17-02: malformed or oversized requests are safe errors and never echo the input.
|
|
#[tokio::test]
|
|
async fn malformed_requests_are_safe_errors_without_echoing_input() {
|
|
let endpoint = completion_endpoint().await;
|
|
|
|
let oversized_token = "s".repeat(2_000);
|
|
for revision in [MODERN_REVISION, LEGACY_REVISION] {
|
|
for (case, params) in [
|
|
(
|
|
"missing ref",
|
|
json!({"argument": {"name": "tone", "value": ""}}),
|
|
),
|
|
(
|
|
"unknown ref type",
|
|
request(json!({"type": "ref/tool", "name": "x"}), "tone", ""),
|
|
),
|
|
(
|
|
"argument is not an object",
|
|
json!({"ref": prompt_ref("greeting"), "argument": "tone"}),
|
|
),
|
|
(
|
|
"oversized token",
|
|
request(prompt_ref("greeting"), "tone", &oversized_token),
|
|
),
|
|
(
|
|
"oversized argument name",
|
|
request(prompt_ref("greeting"), &"n".repeat(200), ""),
|
|
),
|
|
(
|
|
"context with a non-string value",
|
|
json!({
|
|
"ref": prompt_ref("greeting"),
|
|
"argument": {"name": "tone", "value": ""},
|
|
"context": {"arguments": {"region": 7}}
|
|
}),
|
|
),
|
|
] {
|
|
let body = endpoint.on_revision(revision, params).await;
|
|
let (code, message) = error(&body);
|
|
assert_eq!(code, -32602, "{case} on {revision}: {body}");
|
|
assert!(
|
|
message == INVALID_PARAMS || message == NOT_AVAILABLE,
|
|
"{case} on {revision} must be answered with one safe detail: {body}"
|
|
);
|
|
let serialized = body.to_string();
|
|
assert!(
|
|
!serialized.contains(&oversized_token),
|
|
"{case} on {revision} must not echo the client token: {serialized}"
|
|
);
|
|
assert!(
|
|
!serialized.contains(&"n".repeat(200)),
|
|
"{case} on {revision} must not echo the argument name: {serialized}"
|
|
);
|
|
}
|
|
}
|
|
}
|
|
|
|
/// AT-3.17-03: the authorization boundary is the Agent route and its bound snapshot — the other
|
|
/// Agent of the same workspace cannot address this Agent's Prompt or template, and this Agent cannot
|
|
/// address the other Agent's.
|
|
#[tokio::test]
|
|
async fn the_other_agents_snapshot_is_not_addressable() {
|
|
let endpoint = completion_endpoint().await;
|
|
let other_key = endpoint.other_agent_key().await;
|
|
|
|
for revision in [MODERN_REVISION, LEGACY_REVISION] {
|
|
// The other Agent's credential and route complete its own Prompt argument…
|
|
let own = match revision {
|
|
MODERN_REVISION => {
|
|
endpoint
|
|
.modern_for(
|
|
OTHER_AGENT_SLUG,
|
|
&other_key,
|
|
request(prompt_ref("other-agent-prompt"), "tone", ""),
|
|
)
|
|
.await
|
|
}
|
|
_ => {
|
|
endpoint
|
|
.legacy_for(
|
|
OTHER_AGENT_SLUG,
|
|
&other_key,
|
|
request(prompt_ref("other-agent-prompt"), "tone", ""),
|
|
)
|
|
.await
|
|
}
|
|
};
|
|
let (code, message) = error(&own);
|
|
assert_eq!(
|
|
(code, message.as_str()),
|
|
(-32602, NOT_AVAILABLE),
|
|
"the other Agent's Prompt has no argument of that name, so nothing is suggested on {revision}: {own}"
|
|
);
|
|
|
|
// …and cannot address this Agent's bound Prompt or template.
|
|
for request_value in [
|
|
request(prompt_ref("greeting"), "tone", ""),
|
|
request(resource_ref(BOUND_TEMPLATE_URI), "region", ""),
|
|
] {
|
|
let body = match revision {
|
|
MODERN_REVISION => {
|
|
endpoint
|
|
.modern_for(OTHER_AGENT_SLUG, &other_key, request_value)
|
|
.await
|
|
}
|
|
_ => {
|
|
endpoint
|
|
.legacy_for(OTHER_AGENT_SLUG, &other_key, request_value)
|
|
.await
|
|
}
|
|
};
|
|
let (code, message) = error(&body);
|
|
assert_eq!(
|
|
(code, message.as_str()),
|
|
(-32602, NOT_AVAILABLE),
|
|
"a foreign snapshot is not addressable on {revision}: {body}"
|
|
);
|
|
}
|
|
}
|
|
}
|