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
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:
1 parent
1b6db09bd1
commit
54ce770682
357 files changed
+117394
-5115
No files matched your search
@@ -1,12 +1,14 @@
|
||||
use std::collections::BTreeMap;
|
||||
use std::collections::{BTreeMap, BTreeSet};
|
||||
|
||||
use crank_core::ids::{PromptId, ResourceId};
|
||||
use crank_core::{
|
||||
Agent, AgentId, AgentOperationBinding, AgentStatus, AgentVersion, OperationId, SearchableTool,
|
||||
ToolAccessMode, ToolSelectionPolicy, UsagePeriod, WorkspaceId, search_tool_catalog,
|
||||
};
|
||||
use crank_registry::{
|
||||
AgentStateExpectation, AgentVersionRecord, CreateAgentRequest, PublishAgentRequest,
|
||||
SaveAgentCatalogConfigRequest, UpdateAgentSummaryRequest, UsageBucket, UsageQuery,
|
||||
AgentResourceBinding, AgentStateExpectation, AgentVersionRecord, CreateAgentRequest,
|
||||
PublishAgentRequest, SaveAgentCatalogConfigRequest, UpdateAgentSummaryRequest, UsageBucket,
|
||||
UsageQuery, model::AgentPromptBinding,
|
||||
};
|
||||
use serde_json::json;
|
||||
use sha2::{Digest, Sha256};
|
||||
@@ -474,7 +476,8 @@ impl AdminService {
|
||||
let current_version = self
|
||||
.get_agent_version(workspace_id, agent_id, agent.current_draft_version)
|
||||
.await?;
|
||||
let (payload, requested_policy) = payload.into_parts();
|
||||
let (payload, requested_policy, requested_resource_bindings, requested_prompt_bindings) =
|
||||
payload.into_parts();
|
||||
let bindings = payload
|
||||
.into_iter()
|
||||
.map(|binding| AgentOperationBinding {
|
||||
@@ -486,28 +489,64 @@ impl AdminService {
|
||||
enabled: binding.enabled,
|
||||
})
|
||||
.collect::<Vec<_>>();
|
||||
// Tri-state additive-поля: отсутствие сохраняет прежние Resource bindings,
|
||||
// `[]` очищает, список заменяет их в Draft.
|
||||
let resource_bindings = match requested_resource_bindings {
|
||||
Some(items) => items
|
||||
.into_iter()
|
||||
.map(|binding| AgentResourceBinding {
|
||||
resource_id: ResourceId::new(binding.resource_id),
|
||||
resource_version: binding.resource_version,
|
||||
})
|
||||
.collect::<Vec<_>>(),
|
||||
None => current_version.resource_bindings.clone(),
|
||||
};
|
||||
validate_resource_binding_shape(&resource_bindings)?;
|
||||
// Tri-state exact Prompt bindings: отсутствие сохраняет, `[]` очищает,
|
||||
// список заменяет (Story 3.13 AC2).
|
||||
let prompt_bindings = match requested_prompt_bindings {
|
||||
Some(items) => items
|
||||
.into_iter()
|
||||
.map(|binding| AgentPromptBinding {
|
||||
prompt_id: PromptId::new(binding.prompt_id),
|
||||
prompt_version: binding.prompt_version,
|
||||
})
|
||||
.collect::<Vec<_>>(),
|
||||
None => current_version.prompt_bindings.clone(),
|
||||
};
|
||||
validate_prompt_binding_shape(&prompt_bindings)?;
|
||||
self.validate_exact_published_agent_bindings(workspace_id, &bindings)
|
||||
.await?;
|
||||
self.validate_exact_published_resource_bindings(workspace_id, &resource_bindings)
|
||||
.await?;
|
||||
self.validate_exact_published_prompt_bindings(workspace_id, &prompt_bindings)
|
||||
.await?;
|
||||
let tool_selection_policy = requested_policy
|
||||
.unwrap_or_else(|| current_version.snapshot.tool_selection_policy.clone());
|
||||
validate_tool_selection_policy(&tool_selection_policy, &bindings)?;
|
||||
|
||||
let saved_version = self
|
||||
.registry
|
||||
.save_agent_catalog_config_editable(SaveAgentCatalogConfigRequest {
|
||||
workspace_id,
|
||||
agent_id,
|
||||
agent_version: current_version.version,
|
||||
bindings: &bindings,
|
||||
tool_selection_policy: &tool_selection_policy,
|
||||
expected_state,
|
||||
})
|
||||
.save_agent_catalog_config_editable_with_prompts(
|
||||
SaveAgentCatalogConfigRequest {
|
||||
workspace_id,
|
||||
agent_id,
|
||||
agent_version: current_version.version,
|
||||
bindings: &bindings,
|
||||
tool_selection_policy: &tool_selection_policy,
|
||||
resource_bindings: &resource_bindings,
|
||||
expected_state,
|
||||
},
|
||||
&prompt_bindings,
|
||||
)
|
||||
.await?;
|
||||
info!(
|
||||
name: "admin.agent.bindings_saved",
|
||||
agent_id = %agent_id.as_str(),
|
||||
version = saved_version,
|
||||
binding_count = bindings.len(),
|
||||
resource_binding_count = resource_bindings.len(),
|
||||
prompt_binding_count = prompt_bindings.len(),
|
||||
"agent bindings saved"
|
||||
);
|
||||
|
||||
@@ -531,25 +570,36 @@ impl AdminService {
|
||||
&agent_version.bindings,
|
||||
)?;
|
||||
|
||||
// Resource-only Agent валиден: публикация требует хотя бы один enabled Tool
|
||||
// ИЛИ хотя бы один exact Resource binding.
|
||||
if agent_version
|
||||
.bindings
|
||||
.iter()
|
||||
.filter(|binding| binding.enabled)
|
||||
.count()
|
||||
== 0
|
||||
&& agent_version.resource_bindings.is_empty()
|
||||
{
|
||||
return Err(ApiError::conflict_with_context(
|
||||
"agent cannot be published without published enabled tools",
|
||||
"agent cannot be published without published enabled tools or Resource bindings",
|
||||
json!({
|
||||
"agent_id": agent_id.as_str(),
|
||||
"version": version,
|
||||
"binding_count": agent_version.bindings.len()
|
||||
"binding_count": agent_version.bindings.len(),
|
||||
"resource_binding_count": agent_version.resource_bindings.len()
|
||||
}),
|
||||
));
|
||||
}
|
||||
|
||||
self.validate_exact_published_agent_bindings(workspace_id, &agent_version.bindings)
|
||||
.await?;
|
||||
self.validate_exact_published_resource_bindings(
|
||||
workspace_id,
|
||||
&agent_version.resource_bindings,
|
||||
)
|
||||
.await?;
|
||||
self.validate_exact_published_prompt_bindings(workspace_id, &agent_version.prompt_bindings)
|
||||
.await?;
|
||||
|
||||
let published_at = OffsetDateTime::now_utc();
|
||||
|
||||
@@ -639,6 +689,47 @@ impl AdminService {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Точная published Resource Version обязана существовать в этом workspace.
|
||||
/// Чужая/неопубликованная/отсутствующая версии дают один и тот же sanitized 404
|
||||
/// без раскрытия существования.
|
||||
async fn validate_exact_published_resource_bindings(
|
||||
&self,
|
||||
workspace_id: &WorkspaceId,
|
||||
bindings: &[AgentResourceBinding],
|
||||
) -> Result<(), ApiError> {
|
||||
let unresolved = self
|
||||
.registry
|
||||
.unresolved_published_resource_versions(workspace_id, bindings)
|
||||
.await?;
|
||||
if unresolved.is_empty() {
|
||||
return Ok(());
|
||||
}
|
||||
Err(ApiError::not_found_with_context(
|
||||
"published resource version was not found for Agent binding",
|
||||
json!({ "error_code": "agent_resource_binding_not_found" }),
|
||||
))
|
||||
}
|
||||
|
||||
/// Exact Published Prompt Version обязана существовать в этом workspace;
|
||||
/// отсутствующая, чужая и неопубликованная версии неразличимы снаружи.
|
||||
async fn validate_exact_published_prompt_bindings(
|
||||
&self,
|
||||
workspace_id: &WorkspaceId,
|
||||
bindings: &[AgentPromptBinding],
|
||||
) -> Result<(), ApiError> {
|
||||
let unresolved = self
|
||||
.registry
|
||||
.unresolved_published_prompt_versions(workspace_id, bindings)
|
||||
.await?;
|
||||
if unresolved.is_empty() {
|
||||
return Ok(());
|
||||
}
|
||||
Err(ApiError::not_found_with_context(
|
||||
"published prompt version was not found for Agent binding",
|
||||
json!({ "error_code": "agent_prompt_binding_not_found" }),
|
||||
))
|
||||
}
|
||||
|
||||
#[instrument(skip(self), fields(workspace_id = %workspace_id.as_str(), agent_id = %agent_id.as_str()))]
|
||||
pub async fn unpublish_agent(
|
||||
&self,
|
||||
@@ -690,6 +781,57 @@ impl AdminService {
|
||||
}
|
||||
}
|
||||
|
||||
fn validate_resource_binding_shape(bindings: &[AgentResourceBinding]) -> Result<(), ApiError> {
|
||||
let mut seen = BTreeSet::new();
|
||||
for binding in bindings {
|
||||
if binding.resource_version == 0 {
|
||||
return Err(ApiError::validation_with_context(
|
||||
"resource_version must be a positive exact integer",
|
||||
json!({
|
||||
"field": "resource_bindings.resource_version",
|
||||
"resource_id": binding.resource_id.as_str(),
|
||||
}),
|
||||
));
|
||||
}
|
||||
if !seen.insert((binding.resource_id.as_str(), binding.resource_version)) {
|
||||
return Err(ApiError::validation_with_context(
|
||||
"duplicate exact Resource binding is not allowed",
|
||||
json!({
|
||||
"field": "resource_bindings",
|
||||
"resource_id": binding.resource_id.as_str(),
|
||||
"resource_version": binding.resource_version,
|
||||
}),
|
||||
));
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn validate_prompt_binding_shape(bindings: &[AgentPromptBinding]) -> Result<(), ApiError> {
|
||||
let mut seen = BTreeSet::new();
|
||||
for binding in bindings {
|
||||
if binding.prompt_version == 0 {
|
||||
return Err(ApiError::validation_with_context(
|
||||
"prompt_version must be a positive exact integer",
|
||||
json!({
|
||||
"field": "prompt_bindings.prompt_version",
|
||||
"prompt_id": binding.prompt_id.as_str(),
|
||||
}),
|
||||
));
|
||||
}
|
||||
if !seen.insert(binding.prompt_id.as_str()) {
|
||||
return Err(ApiError::validation_with_context(
|
||||
"duplicate exact Prompt binding is not allowed",
|
||||
json!({
|
||||
"field": "prompt_bindings",
|
||||
"prompt_id": binding.prompt_id.as_str(),
|
||||
}),
|
||||
));
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn validate_tool_selection_policy(
|
||||
policy: &ToolSelectionPolicy,
|
||||
bindings: &[AgentOperationBinding],
|
||||
|
||||
Reference in new issue
Block a user