feat(epic3): deliver the accepted Epic 3 scope through Story 3.17
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.
This commit is contained in:
bsodfather committed 2026-10-25 09:08:22 +00:00
1 parent 1b6db09bd1
commit 54ce770682
357 files changed
+117394 -5115

No files matched your search

+26 -231
View File
@@ -1,24 +1,20 @@
use std::{collections::BTreeSet, sync::Arc};
//! Domain of the shared `search_tools` command (Story 3.1, decision D-4).
//!
//! The wire-level shared entry that used to live in this file (`handle_catalog_tool_call`, carrying
//! the request envelope, the response mode, the protocol revision and an `axum::Response`) is
//! replaced by `protocol::command::handle_tools_command`: the neutral Tools boundary owns the
//! command, while the catalog-search domain stays here and never sees the wire. The reserved
//! `_crank_confirmation_token` handling, the proxy-revision check and the approval policy moved with
//! the command, not with the domain.
use axum::{http::StatusCode, response::Response};
use crank_core::{CorrelationContext, ToolAccessMode, search_tool_catalog};
use std::collections::BTreeSet;
use crank_core::search_tool_catalog;
use crank_registry::PublishedAgentCatalog;
use crank_trace::{ErrorCategory, Stage, StageOutcome};
use serde::Deserialize;
use serde_json::{Value, json};
use crate::{
app::{
AppState, handle_tool_call, resolve_generated_tool, take_confirmation_token,
tool_error_response,
},
auth::VerifiedMachineCredential,
jsonrpc::{jsonrpc_error, jsonrpc_result, request_id},
manifest::{CALL_TOOL_NAME, SEARCH_TOOLS_NAME, searchable_tools},
session::SessionState,
tool_error::{McpControlError, control_tool_error_contract, execution_locale},
transport::{ResponseMode, transport_response},
};
use crate::manifest::searchable_tools;
#[derive(Debug, Deserialize)]
struct SearchToolsArguments {
@@ -28,161 +24,18 @@ struct SearchToolsArguments {
max_results: Option<usize>,
}
#[derive(Debug, Deserialize)]
struct ProxyToolCallArguments {
name: String,
#[serde(default)]
arguments: Value,
catalog_revision: String,
}
#[allow(clippy::too_many_arguments)]
pub(super) async fn handle_catalog_tool_call(
state: Arc<AppState>,
session: &SessionState,
message: &Value,
response_mode: ResponseMode,
credential: &VerifiedMachineCredential,
catalog: &PublishedAgentCatalog,
tool_name: &str,
arguments: Value,
transport_correlation: &CorrelationContext,
) -> Response {
let transport_request_id = transport_correlation.request_id().as_str();
match catalog.tool_selection_policy.mode {
ToolAccessMode::Direct => {
execute_catalog_tool(
state,
session,
message,
response_mode,
credential,
catalog,
tool_name,
arguments,
transport_correlation,
)
.await
}
ToolAccessMode::Search if tool_name == SEARCH_TOOLS_NAME => {
handle_search_tools(message, response_mode, session, catalog, arguments)
}
ToolAccessMode::Search if tool_name == CALL_TOOL_NAME => {
let proxy: ProxyToolCallArguments = match serde_json::from_value(arguments) {
Ok(proxy) => proxy,
Err(error) => {
return invalid_arguments_response(
message,
response_mode,
&session.protocol_version,
error.to_string(),
);
}
};
if proxy.catalog_revision != catalog_revision(catalog) {
return tool_error_response(
message,
response_mode,
&session.protocol_version,
control_tool_error_contract(
McpControlError::CatalogRevisionChanged,
transport_request_id,
transport_correlation.trace_id().as_str(),
execution_locale(message),
),
);
}
execute_catalog_tool(
state,
session,
message,
response_mode,
credential,
catalog,
&proxy.name,
proxy.arguments,
transport_correlation,
)
.await
}
ToolAccessMode::Search => {
tool_not_found_response(message, response_mode, &session.protocol_version, tool_name)
}
}
}
#[allow(clippy::too_many_arguments)]
async fn execute_catalog_tool(
state: Arc<AppState>,
session: &SessionState,
message: &Value,
response_mode: ResponseMode,
credential: &VerifiedMachineCredential,
catalog: &PublishedAgentCatalog,
tool_name: &str,
mut arguments: Value,
transport_correlation: &CorrelationContext,
) -> Response {
let resolve_span = Stage::McpToolsResolve.span();
let resolved = resolve_span.in_scope(|| resolve_generated_tool(&catalog.tools, tool_name));
let resolved = match resolved {
Some(resolved) => {
StageOutcome::Success.record(&resolve_span);
drop(resolve_span);
resolved
}
None => {
StageOutcome::Error.record(&resolve_span);
ErrorCategory::Catalog.record(&resolve_span);
drop(resolve_span);
return tool_not_found_response(
message,
response_mode,
&session.protocol_version,
tool_name,
);
}
};
let confirmation_token = take_confirmation_token(&mut arguments);
handle_tool_call(
state,
session,
message,
response_mode,
credential,
resolved,
arguments,
confirmation_token,
transport_correlation,
)
.await
}
fn handle_search_tools(
message: &Value,
response_mode: ResponseMode,
session: &SessionState,
/// The domain result of the catalog search tool, without any wire wrapping.
///
/// The error is the invalid-params detail the adapter answers with; a domain failure never carries a
/// response shape of its own.
pub(crate) fn search_tools_outcome(
catalog: &PublishedAgentCatalog,
arguments: Value,
) -> Response {
let search: SearchToolsArguments = match serde_json::from_value(arguments) {
Ok(search) => search,
Err(error) => {
return invalid_arguments_response(
message,
response_mode,
&session.protocol_version,
error.to_string(),
);
}
};
) -> Result<Value, String> {
let search: SearchToolsArguments =
serde_json::from_value(arguments).map_err(|error| error.to_string())?;
if search.query.trim().is_empty() {
return invalid_arguments_response(
message,
response_mode,
&session.protocol_version,
"query must not be empty".to_owned(),
);
return Err("query must not be empty".to_owned());
}
let known_group_ids = catalog
.tool_selection_policy
@@ -195,12 +48,7 @@ fn handle_search_tools(
.iter()
.find(|group_id| !known_group_ids.contains(group_id.as_str()))
{
return invalid_arguments_response(
message,
response_mode,
&session.protocol_version,
format!("unknown tool group {group_id}"),
);
return Err(format!("unknown tool group {group_id}"));
}
let configured_limit = catalog.tool_selection_policy.search.max_results;
@@ -223,62 +71,9 @@ fn handle_search_tools(
})
})
.collect::<Vec<_>>();
let result = json!({
"catalog_revision": catalog_revision(catalog),
Ok(json!({
"catalog_revision": catalog.catalog_revision,
"tools": tools,
});
let text = serde_json::to_string_pretty(&result).unwrap_or_else(|_| result.to_string());
transport_response(
StatusCode::OK,
jsonrpc_result(
request_id(message),
json!({
"content": [{"type": "text", "text": text}],
"structuredContent": result,
"isError": false
}),
),
response_mode,
None,
Some(&session.protocol_version),
)
}
fn catalog_revision(catalog: &PublishedAgentCatalog) -> String {
catalog.catalog_revision.clone()
}
fn invalid_arguments_response(
message: &Value,
response_mode: ResponseMode,
protocol_version: &str,
detail: String,
) -> Response {
transport_response(
StatusCode::OK,
jsonrpc_error(request_id(message), -32602, detail),
response_mode,
None,
Some(protocol_version),
)
}
fn tool_not_found_response(
message: &Value,
response_mode: ResponseMode,
protocol_version: &str,
tool_name: &str,
) -> Response {
transport_response(
StatusCode::OK,
jsonrpc_error(
request_id(message),
-32602,
format!("tool {tool_name} was not found"),
),
response_mode,
None,
Some(protocol_version),
)
}))
}