Files
crank/apps/mcp-server/tests/integration/static_resources/lifecycle.rs
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

126 lines
5.0 KiB
Rust

//! Story 3.8 AC04 / AT-3.8-04: archiving a Published Resource Version after the Agent snapshot is
//! fixed must not break reproducible reads of the exact immutable snapshot, while archive refuses new
//! bindings. Explicit security revocation stays a separate audited transition and is NOT aliased to
//! archive here — its API does not exist yet (reported as a gap, not invented).
use super::super::common::test_workspace_id;
use super::fixtures::*;
#[tokio::test]
async fn archive_keeps_the_exact_published_snapshot_readable_for_the_bound_agent() {
let endpoint = standard_endpoint("archive_read").await;
endpoint.archive_text().await;
// The immutable publication row itself is untouched by archive.
let publication = endpoint
.registry
.resolve_resource_publication(test_workspace_id().as_str(), &endpoint.text.id, 1)
.await
.expect("archiving must not remove the exact published version");
assert_eq!(
publication.publication.digest,
digest_hex(&endpoint.text.bytes),
"archive must not rewrite the published digest"
);
let expected = String::from_utf8(endpoint.text.bytes.clone()).expect("text fixture is UTF-8");
for revision in supported_revisions() {
let body =
json_body(read_resource(&endpoint, &revision, &endpoint.text.uri, None).await).await;
let result = result_of(&body, &format!("post-archive resources/read on {revision}"));
let contents = result["contents"].as_array().unwrap_or_else(|| {
panic!("post-archive read must return contents on {revision}: {body}")
});
assert_eq!(
contents.len(),
1,
"post-archive read must return one content entry on {revision}: {body}"
);
assert_eq!(
contents[0]["text"].as_str(),
Some(expected.as_str()),
"post-archive read must return the exact immutable snapshot on {revision}: {body}"
);
}
}
/// Archive refuses new bindings, including for a still-mutable Draft Agent version.
#[tokio::test]
async fn archive_refuses_new_resource_bindings() {
let endpoint = standard_endpoint("archive_binding_guard").await;
let binding = crank_registry::AgentResourceBinding {
resource_id: endpoint.text.id.clone(),
resource_version: 1,
};
// Positive control: while the Resource is published and active, a Draft Agent accepts the binding.
endpoint
.registry
.save_agent_catalog_config(crank_registry::SaveAgentCatalogConfigRequest {
workspace_id: &test_workspace_id(),
agent_id: &endpoint.draft_agent_id,
agent_version: 1,
bindings: &[],
tool_selection_policy: &crank_core::ToolSelectionPolicy::default(),
resource_bindings: std::slice::from_ref(&binding),
expected_state: None,
})
.await
.expect("an active published Resource must be bindable");
// Drop the control binding again so the post-archive attempt is a genuinely new binding.
endpoint
.registry
.save_agent_catalog_config(crank_registry::SaveAgentCatalogConfigRequest {
workspace_id: &test_workspace_id(),
agent_id: &endpoint.draft_agent_id,
agent_version: 1,
bindings: &[],
tool_selection_policy: &crank_core::ToolSelectionPolicy::default(),
resource_bindings: &[],
expected_state: None,
})
.await
.expect("a Draft Agent must stay mutable");
endpoint.archive_text().await;
let denied = endpoint
.registry
.save_agent_catalog_config(crank_registry::SaveAgentCatalogConfigRequest {
workspace_id: &test_workspace_id(),
agent_id: &endpoint.draft_agent_id,
agent_version: 1,
bindings: &[],
tool_selection_policy: &crank_core::ToolSelectionPolicy::default(),
resource_bindings: &[binding],
expected_state: None,
})
.await;
assert!(
denied.is_err(),
"an archived Resource must not be accepted as a new Agent binding, got {denied:?}"
);
let rows: i64 = sqlx::query_scalar(
"select count(*) from agent_resource_bindings where agent_id = $1 and agent_version = 1",
)
.bind(endpoint.draft_agent_id.as_str())
.fetch_one(endpoint.registry.pool())
.await
.expect("binding rows must be queryable");
assert_eq!(rows, 0, "a refused binding must not persist any row");
// Sanity: the refused attempt must not have been a no-op for another reason.
let published = endpoint
.registry
.get_agent_version(&test_workspace_id(), &endpoint.agent_id, 1)
.await
.expect("the bound Agent version must be readable")
.expect("the bound Agent version must exist");
assert_eq!(
published.resource_bindings.len(),
3,
"the published Agent snapshot must keep its three exact Resource bindings: {published:?}"
);
}