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.
874 lines
25 KiB
Rust
874 lines
25 KiB
Rust
use crank_artifacts::ArtifactRef;
|
||
use crank_core::ids::{PromptId, ResourceId};
|
||
use crank_core::{
|
||
Agent, AgentId, AgentOperationBinding, AgentStatus, AgentVersion, ApprovalRequest,
|
||
ApprovalRequestId, ApprovalRequestStatus, AuthProfile, DescriptorId, ExecutionErrorCode,
|
||
ExportMode, InvitationToken, InvocationLevel, InvocationLog, InvocationLogId, InvocationSource,
|
||
InvocationStatus, MembershipRole, OnboardingProjection, Operation, OperationId,
|
||
OperationSecurityLevel, OperationStatus, PlatformApiKey, PlatformApiKeyId, ProductEvent,
|
||
ProductEventId, ProductEventKind, Protocol, SampleId, Secret, SecretId, SecretVersion,
|
||
ToolSelectionPolicy, UsagePeriod, UsageRollup, User, UserId, UserSessionId, Workspace,
|
||
WorkspaceId,
|
||
};
|
||
use crank_mapping::MappingSet;
|
||
use crank_schema::Schema;
|
||
use serde::{Deserialize, Serialize};
|
||
use serde_json::Value;
|
||
use time::OffsetDateTime;
|
||
|
||
macro_rules! define_registry_id {
|
||
($name:ident) => {
|
||
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize)]
|
||
pub struct $name(String);
|
||
|
||
impl $name {
|
||
pub fn new(value: impl Into<String>) -> Self {
|
||
Self(value.into())
|
||
}
|
||
|
||
pub fn as_str(&self) -> &str {
|
||
&self.0
|
||
}
|
||
}
|
||
|
||
impl From<String> for $name {
|
||
fn from(value: String) -> Self {
|
||
Self(value)
|
||
}
|
||
}
|
||
|
||
impl From<&str> for $name {
|
||
fn from(value: &str) -> Self {
|
||
Self(value.to_owned())
|
||
}
|
||
}
|
||
};
|
||
}
|
||
|
||
mod artifact_source;
|
||
|
||
pub use artifact_source::*;
|
||
|
||
pub mod resource;
|
||
|
||
mod prompt;
|
||
|
||
pub use prompt::*;
|
||
|
||
pub use resource::*;
|
||
|
||
mod import_plan;
|
||
|
||
pub use import_plan::*;
|
||
|
||
mod onboarding_import;
|
||
|
||
pub use onboarding_import::*;
|
||
|
||
mod usage;
|
||
|
||
pub use usage::*;
|
||
|
||
define_registry_id!(YamlImportJobId);
|
||
define_registry_id!(ImportJobId);
|
||
define_registry_id!(ImportPlanId);
|
||
define_registry_id!(WorkspaceUpstreamId);
|
||
|
||
pub type RegistryOperation = Operation<Schema, MappingSet>;
|
||
|
||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||
pub struct Page<T> {
|
||
pub items: Vec<T>,
|
||
pub total: u64,
|
||
}
|
||
|
||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||
pub struct WorkspaceRecord {
|
||
pub workspace: Workspace,
|
||
}
|
||
|
||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||
pub struct MembershipRecord {
|
||
pub workspace_id: WorkspaceId,
|
||
pub user: User,
|
||
pub role: MembershipRole,
|
||
pub created_at: OffsetDateTime,
|
||
}
|
||
|
||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||
pub struct WorkspaceMembershipRecord {
|
||
pub workspace: Workspace,
|
||
pub role: MembershipRole,
|
||
}
|
||
|
||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||
pub struct AuthUserRecord {
|
||
pub user: User,
|
||
pub password_hash: String,
|
||
}
|
||
|
||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||
pub struct SessionRecord {
|
||
pub session_id: UserSessionId,
|
||
pub user: User,
|
||
pub memberships: Vec<WorkspaceMembershipRecord>,
|
||
pub current_workspace_id: Option<WorkspaceId>,
|
||
pub csrf_hash: Option<String>,
|
||
}
|
||
|
||
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
|
||
pub struct AdminBootstrapContractRecord {
|
||
pub id: String,
|
||
pub email: String,
|
||
pub display_name: String,
|
||
pub status: String,
|
||
#[serde(with = "time::serde::rfc3339")]
|
||
pub expires_at: OffsetDateTime,
|
||
#[serde(with = "time::serde::rfc3339")]
|
||
pub created_at: OffsetDateTime,
|
||
#[serde(with = "time::serde::rfc3339::option")]
|
||
pub used_at: Option<OffsetDateTime>,
|
||
}
|
||
|
||
#[derive(Clone, Debug, PartialEq, Eq)]
|
||
pub struct CreateAdminBootstrapContractRequest<'a> {
|
||
pub id: &'a str,
|
||
pub token_hash: &'a str,
|
||
pub email: &'a str,
|
||
pub display_name: &'a str,
|
||
pub expires_at: &'a OffsetDateTime,
|
||
}
|
||
|
||
#[derive(Clone, Debug, PartialEq, Eq)]
|
||
pub struct ConsumeAdminBootstrapContractRequest<'a> {
|
||
pub token_hash: &'a str,
|
||
pub password_hash: &'a str,
|
||
pub now: &'a OffsetDateTime,
|
||
}
|
||
|
||
#[derive(Clone, Debug, PartialEq, Eq)]
|
||
pub struct AdminSecurityAuditRequest<'a> {
|
||
pub id: &'a str,
|
||
pub action: &'a str,
|
||
pub outcome: &'a str,
|
||
pub actor_user_id: Option<&'a UserId>,
|
||
pub session_id: Option<&'a UserSessionId>,
|
||
pub request_id: Option<&'a str>,
|
||
pub trace_id: Option<&'a str>,
|
||
pub source: &'a str,
|
||
}
|
||
|
||
#[derive(Clone, Debug, PartialEq, Eq)]
|
||
pub struct RecoverAdminPasswordRequest<'a> {
|
||
pub email: &'a str,
|
||
pub password_hash: &'a str,
|
||
pub audit_id: &'a str,
|
||
}
|
||
|
||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||
pub struct InvitationRecord {
|
||
pub invitation: InvitationToken,
|
||
}
|
||
|
||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||
pub struct PlatformApiKeyRecord {
|
||
pub api_key: PlatformApiKey,
|
||
}
|
||
|
||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||
pub struct ApprovalRequestRecord {
|
||
pub approval: ApprovalRequest,
|
||
}
|
||
|
||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||
pub struct SecretRecord {
|
||
pub secret: Secret,
|
||
}
|
||
|
||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||
pub struct SecretVersionRecord {
|
||
pub secret_version: SecretVersion,
|
||
pub master_key_epoch: i64,
|
||
pub target_ciphertext: Option<String>,
|
||
pub target_key_version: Option<String>,
|
||
pub target_master_key_epoch: Option<i64>,
|
||
}
|
||
|
||
pub const MASTER_KEY_CIPHER_CONTRACT: &str = "secret-envelope-v2/aes-256-gcm-hkdf-sha256";
|
||
|
||
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
|
||
pub struct MasterKeyIdentityRecord {
|
||
pub epoch: i64,
|
||
pub fingerprint: String,
|
||
pub cipher_contract: String,
|
||
pub status: String,
|
||
pub backup_ref: Option<String>,
|
||
#[serde(with = "time::serde::rfc3339")]
|
||
pub created_at: OffsetDateTime,
|
||
#[serde(with = "time::serde::rfc3339::option")]
|
||
pub activated_at: Option<OffsetDateTime>,
|
||
#[serde(with = "time::serde::rfc3339::option")]
|
||
pub retired_at: Option<OffsetDateTime>,
|
||
}
|
||
|
||
#[derive(Clone, Debug, PartialEq, Eq)]
|
||
pub struct MasterKeyIdentityCandidate<'a> {
|
||
pub epoch: i64,
|
||
pub fingerprint: &'a str,
|
||
pub cipher_contract: &'a str,
|
||
pub observed_at: &'a OffsetDateTime,
|
||
}
|
||
|
||
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
|
||
pub struct MasterKeyRotationRecord {
|
||
pub id: String,
|
||
pub source_epoch: i64,
|
||
pub target_epoch: i64,
|
||
pub target_fingerprint: String,
|
||
pub state: String,
|
||
pub backup_ref: Option<String>,
|
||
pub checkpoint_secret_id: Option<String>,
|
||
pub total_secret_versions: i64,
|
||
pub processed_secret_versions: i64,
|
||
pub verified_secret_versions: i64,
|
||
pub failure_code: Option<String>,
|
||
#[serde(with = "time::serde::rfc3339")]
|
||
pub created_at: OffsetDateTime,
|
||
#[serde(with = "time::serde::rfc3339")]
|
||
pub updated_at: OffsetDateTime,
|
||
}
|
||
|
||
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
|
||
pub struct MasterKeyRotationStatus {
|
||
pub active_identity: Option<MasterKeyIdentityRecord>,
|
||
pub rotations: Vec<MasterKeyRotationRecord>,
|
||
}
|
||
|
||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||
pub struct WorkspaceUpstream {
|
||
pub id: WorkspaceUpstreamId,
|
||
pub workspace_id: WorkspaceId,
|
||
pub name: String,
|
||
pub base_url: String,
|
||
pub static_headers: Value,
|
||
pub auth_profile_id: Option<String>,
|
||
pub created_at: OffsetDateTime,
|
||
pub updated_at: OffsetDateTime,
|
||
}
|
||
|
||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||
pub struct AgentSummary {
|
||
pub id: AgentId,
|
||
pub workspace_id: WorkspaceId,
|
||
pub slug: String,
|
||
pub display_name: String,
|
||
pub description: String,
|
||
pub status: AgentStatus,
|
||
pub current_draft_version: u32,
|
||
pub latest_published_version: Option<u32>,
|
||
pub catalog_revision: i64,
|
||
pub created_at: OffsetDateTime,
|
||
pub updated_at: OffsetDateTime,
|
||
pub published_at: Option<OffsetDateTime>,
|
||
}
|
||
|
||
/// Точная опубликованная Resource Version, закреплённая за конкретной версией
|
||
/// Agent (Story 3.7 AC04): typed binding, а не JSON-заместитель и не `latest`.
|
||
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
|
||
pub struct AgentResourceBinding {
|
||
pub resource_id: ResourceId,
|
||
pub resource_version: u32,
|
||
}
|
||
|
||
/// Точная Published Prompt Version в snapshot версии Agent (Story 3.13).
|
||
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
|
||
pub struct AgentPromptBinding {
|
||
pub prompt_id: PromptId,
|
||
pub prompt_version: u32,
|
||
}
|
||
|
||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||
pub struct AgentVersionRecord {
|
||
pub agent_id: AgentId,
|
||
pub workspace_id: WorkspaceId,
|
||
pub version: u32,
|
||
pub status: AgentStatus,
|
||
pub created_at: OffsetDateTime,
|
||
pub snapshot: AgentVersion,
|
||
pub bindings: Vec<AgentOperationBinding>,
|
||
/// Отдельный typed список exact Published Resource Versions рядом с Operation bindings.
|
||
#[serde(default)]
|
||
pub resource_bindings: Vec<AgentResourceBinding>,
|
||
/// Отдельный typed список exact Published Prompt Versions (Story 3.13).
|
||
#[serde(default)]
|
||
pub prompt_bindings: Vec<AgentPromptBinding>,
|
||
}
|
||
|
||
#[derive(Clone, Debug, PartialEq, Eq)]
|
||
pub struct AgentStateExpectation {
|
||
pub status: AgentStatus,
|
||
pub current_draft_version: u32,
|
||
pub latest_published_version: Option<u32>,
|
||
pub catalog_revision: i64,
|
||
pub updated_at: OffsetDateTime,
|
||
}
|
||
|
||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||
pub struct PublishedAgentTool {
|
||
pub workspace_id: WorkspaceId,
|
||
pub workspace_slug: String,
|
||
pub agent_id: AgentId,
|
||
pub agent_slug: String,
|
||
pub operation: RegistryOperation,
|
||
pub tool_name: String,
|
||
pub tool_title: String,
|
||
pub tool_description: String,
|
||
}
|
||
|
||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||
pub struct PublishedAgentCatalog {
|
||
pub agent_version: u32,
|
||
pub catalog_revision: String,
|
||
pub tool_selection_policy: ToolSelectionPolicy,
|
||
pub tools: Vec<PublishedAgentTool>,
|
||
/// Точные Resource bindings того же `agent_version`/`catalog_revision` из той же
|
||
/// read-транзакции каталога (Story 3.7 AC04).
|
||
#[serde(default)]
|
||
pub resources: Vec<AgentResourceBinding>,
|
||
/// Точные Prompt bindings того же `agent_version`/`catalog_revision` из той же
|
||
/// read-транзакции каталога (Story 3.14).
|
||
#[serde(default)]
|
||
pub prompts: Vec<AgentPromptBinding>,
|
||
}
|
||
|
||
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
|
||
pub struct OperationSummary {
|
||
pub id: OperationId,
|
||
pub workspace_id: WorkspaceId,
|
||
pub name: String,
|
||
pub display_name: String,
|
||
pub category: String,
|
||
pub protocol: Protocol,
|
||
pub security_level: OperationSecurityLevel,
|
||
pub target_url: String,
|
||
pub target_action: String,
|
||
pub status: OperationStatus,
|
||
pub current_draft_version: u32,
|
||
pub latest_published_version: Option<u32>,
|
||
pub can_delete: bool,
|
||
pub created_at: OffsetDateTime,
|
||
pub updated_at: OffsetDateTime,
|
||
pub published_at: Option<OffsetDateTime>,
|
||
}
|
||
|
||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||
pub struct OperationUsageSummary {
|
||
pub operation_id: OperationId,
|
||
pub calls_today: u64,
|
||
pub error_rate_pct: f64,
|
||
pub avg_latency_ms: u64,
|
||
}
|
||
|
||
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
|
||
pub struct OperationAgentRef {
|
||
pub operation_id: OperationId,
|
||
pub agent_id: AgentId,
|
||
pub agent_slug: String,
|
||
pub display_name: String,
|
||
}
|
||
|
||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||
pub struct OperationVersionRecord {
|
||
pub operation_id: OperationId,
|
||
pub workspace_id: WorkspaceId,
|
||
pub version: u32,
|
||
pub status: OperationStatus,
|
||
pub change_note: Option<String>,
|
||
pub created_at: OffsetDateTime,
|
||
pub created_by: Option<String>,
|
||
pub snapshot: RegistryOperation,
|
||
}
|
||
|
||
#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)]
|
||
#[serde(rename_all = "snake_case")]
|
||
pub enum SampleKind {
|
||
InputJson,
|
||
OutputJson,
|
||
YamlImportSource,
|
||
}
|
||
|
||
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
|
||
pub struct OperationSampleMetadata {
|
||
pub id: SampleId,
|
||
pub operation_id: OperationId,
|
||
pub version: u32,
|
||
pub sample_kind: SampleKind,
|
||
pub storage_ref: String,
|
||
pub content_type: String,
|
||
pub file_name: Option<String>,
|
||
#[serde(with = "time::serde::rfc3339")]
|
||
pub created_at: OffsetDateTime,
|
||
}
|
||
|
||
#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)]
|
||
#[serde(rename_all = "snake_case")]
|
||
pub enum DescriptorKind {
|
||
ProtoUpload,
|
||
DescriptorSet,
|
||
ReflectionSnapshot,
|
||
WsdlUpload,
|
||
XsdUpload,
|
||
}
|
||
|
||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||
pub struct DescriptorMetadata {
|
||
pub id: DescriptorId,
|
||
pub operation_id: Option<OperationId>,
|
||
pub version: Option<u32>,
|
||
pub descriptor_kind: DescriptorKind,
|
||
pub storage_ref: String,
|
||
pub source_name: Option<String>,
|
||
pub package_index: Option<Value>,
|
||
#[serde(with = "time::serde::rfc3339")]
|
||
pub created_at: OffsetDateTime,
|
||
}
|
||
|
||
#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)]
|
||
#[serde(rename_all = "snake_case")]
|
||
pub enum YamlImportJobStatus {
|
||
Pending,
|
||
Completed,
|
||
Failed,
|
||
}
|
||
|
||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||
pub struct YamlImportJob {
|
||
pub id: YamlImportJobId,
|
||
pub source_sample_id: Option<SampleId>,
|
||
pub status: YamlImportJobStatus,
|
||
pub format_version: String,
|
||
pub mode: ExportMode,
|
||
pub result_operation_id: Option<OperationId>,
|
||
pub result_version: Option<u32>,
|
||
pub error_text: Option<String>,
|
||
#[serde(with = "time::serde::rfc3339")]
|
||
pub created_at: OffsetDateTime,
|
||
#[serde(with = "time::serde::rfc3339::option")]
|
||
pub finished_at: Option<OffsetDateTime>,
|
||
}
|
||
|
||
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
|
||
pub struct YamlImportJobCompletion {
|
||
pub status: YamlImportJobStatus,
|
||
pub result_operation_id: Option<OperationId>,
|
||
pub result_version: Option<u32>,
|
||
pub error_text: Option<String>,
|
||
#[serde(with = "time::serde::rfc3339")]
|
||
pub finished_at: OffsetDateTime,
|
||
}
|
||
|
||
#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)]
|
||
#[serde(rename_all = "snake_case")]
|
||
pub enum ImportJobStatus {
|
||
Pending,
|
||
Completed,
|
||
Failed,
|
||
}
|
||
|
||
#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)]
|
||
#[serde(rename_all = "snake_case")]
|
||
pub enum ImportJobKind {
|
||
OpenApi,
|
||
}
|
||
|
||
/// The bounded, opaque authority retained with an OpenAPI import job.
|
||
/// It is persisted inside the existing JSONB payload, never exposed by the
|
||
/// admin response, and is rechecked against workspace-scoped metadata at
|
||
/// apply time.
|
||
#[derive(Clone, Debug, PartialEq, Eq)]
|
||
pub struct ImportJobSourceEnvelope {
|
||
pub source_id: ArtifactSourceId,
|
||
pub digest: ArtifactRef,
|
||
}
|
||
|
||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||
pub struct ImportJob {
|
||
pub id: ImportJobId,
|
||
pub workspace_id: WorkspaceId,
|
||
pub kind: ImportJobKind,
|
||
pub source_format: String,
|
||
pub source_version: Option<String>,
|
||
pub status: ImportJobStatus,
|
||
pub preview_payload: Value,
|
||
pub created_operation_ids: Value,
|
||
pub error_text: Option<String>,
|
||
#[serde(with = "time::serde::rfc3339")]
|
||
pub created_at: OffsetDateTime,
|
||
#[serde(with = "time::serde::rfc3339")]
|
||
pub expires_at: OffsetDateTime,
|
||
#[serde(with = "time::serde::rfc3339::option")]
|
||
pub finished_at: Option<OffsetDateTime>,
|
||
}
|
||
|
||
#[derive(Clone, Debug, PartialEq)]
|
||
pub struct CreateImportJobRequest<'a> {
|
||
pub id: &'a ImportJobId,
|
||
pub workspace_id: &'a WorkspaceId,
|
||
pub kind: ImportJobKind,
|
||
pub source_format: &'a str,
|
||
pub source_version: Option<&'a str>,
|
||
pub status: ImportJobStatus,
|
||
pub source: &'a ImportJobSourceEnvelope,
|
||
pub preview_payload: &'a Value,
|
||
pub created_at: &'a OffsetDateTime,
|
||
pub expires_at: &'a OffsetDateTime,
|
||
}
|
||
|
||
#[derive(Clone, Debug, PartialEq)]
|
||
pub struct FinishImportJobRequest<'a> {
|
||
pub id: &'a ImportJobId,
|
||
pub status: ImportJobStatus,
|
||
pub created_operation_ids: &'a Value,
|
||
pub error_text: Option<&'a str>,
|
||
pub finished_at: &'a OffsetDateTime,
|
||
}
|
||
|
||
#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)]
|
||
#[serde(rename_all = "snake_case")]
|
||
pub enum ImportConflictMode {
|
||
Skip,
|
||
Rename,
|
||
}
|
||
|
||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||
pub struct ImportOperationDraft {
|
||
pub operation_key: String,
|
||
pub operation: RegistryOperation,
|
||
}
|
||
|
||
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
|
||
pub struct AppliedImportOperation {
|
||
pub operation_key: String,
|
||
pub operation_id: OperationId,
|
||
pub name: String,
|
||
pub version: u32,
|
||
pub renamed_from: Option<String>,
|
||
}
|
||
|
||
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
|
||
pub struct SkippedImportOperation {
|
||
pub operation_key: String,
|
||
pub name: String,
|
||
pub reason: String,
|
||
}
|
||
|
||
#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize)]
|
||
pub struct ImportJobApplyResult {
|
||
pub application_key: String,
|
||
pub created: Vec<AppliedImportOperation>,
|
||
pub skipped: Vec<SkippedImportOperation>,
|
||
}
|
||
|
||
/// Result of one bounded import-source maintenance pass.
|
||
///
|
||
/// The caller may schedule another pass when `more_work` is true. The report
|
||
/// intentionally contains only counts so it is safe to use in telemetry.
|
||
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
|
||
pub struct ImportJobCleanupReport {
|
||
pub deleted_jobs: u64,
|
||
pub detached_sources: u64,
|
||
pub more_work: bool,
|
||
}
|
||
|
||
#[derive(Clone, Debug, PartialEq)]
|
||
pub struct ApplyImportJobRequest<'a> {
|
||
pub id: &'a ImportJobId,
|
||
pub workspace_id: &'a WorkspaceId,
|
||
pub application_key: &'a str,
|
||
pub conflict_mode: ImportConflictMode,
|
||
pub operations: &'a [ImportOperationDraft],
|
||
/// Outcomes determined before the registry transaction (for example,
|
||
/// selected OpenAPI keys absent from the immutable preview). They are
|
||
/// persisted with the canonical result so retries remain equivalent.
|
||
pub pre_skipped: &'a [SkippedImportOperation],
|
||
pub finished_at: &'a OffsetDateTime,
|
||
}
|
||
|
||
#[derive(Clone, Debug, PartialEq)]
|
||
pub struct CreateInvocationLogRequest<'a> {
|
||
pub log: &'a InvocationLog,
|
||
}
|
||
|
||
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
|
||
pub enum InvocationHistoryLossCategory {
|
||
Unavailable,
|
||
InvalidRecord,
|
||
}
|
||
|
||
impl InvocationHistoryLossCategory {
|
||
pub fn as_str(self) -> &'static str {
|
||
match self {
|
||
Self::Unavailable => "unavailable",
|
||
Self::InvalidRecord => "invalid_record",
|
||
}
|
||
}
|
||
}
|
||
|
||
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
|
||
pub struct InvocationHistoryLoss {
|
||
pub category: InvocationHistoryLossCategory,
|
||
}
|
||
|
||
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
|
||
pub enum InvocationHistoryWriteOutcome {
|
||
Recorded,
|
||
Lost(InvocationHistoryLoss),
|
||
}
|
||
|
||
impl InvocationHistoryWriteOutcome {
|
||
pub fn loss(self) -> Option<InvocationHistoryLoss> {
|
||
match self {
|
||
Self::Recorded => None,
|
||
Self::Lost(loss) => Some(loss),
|
||
}
|
||
}
|
||
}
|
||
|
||
#[derive(Clone, Debug, PartialEq, Eq)]
|
||
pub struct ListInvocationLogsQuery<'a> {
|
||
pub workspace_id: &'a WorkspaceId,
|
||
pub level: Option<InvocationLevel>,
|
||
pub status: Option<InvocationStatus>,
|
||
pub outcome_group: Option<UsageOutcomeGroup>,
|
||
pub search_text: Option<&'a str>,
|
||
pub source: Option<InvocationSource>,
|
||
pub operation_id: Option<&'a OperationId>,
|
||
pub agent_id: Option<&'a AgentId>,
|
||
pub created_after: Option<&'a str>,
|
||
pub created_before: Option<&'a str>,
|
||
pub cursor_created_at: Option<&'a str>,
|
||
pub cursor_id: Option<&'a InvocationLogId>,
|
||
pub limit: u32,
|
||
}
|
||
|
||
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
||
pub enum UsageBucket {
|
||
Hour,
|
||
Day,
|
||
Week,
|
||
Month,
|
||
}
|
||
|
||
#[derive(Clone, Debug, PartialEq, Eq)]
|
||
pub struct UsageQuery<'a> {
|
||
pub workspace_id: &'a WorkspaceId,
|
||
pub period: UsagePeriod,
|
||
pub source: Option<InvocationSource>,
|
||
pub created_after: &'a str,
|
||
pub created_before: &'a str,
|
||
pub bucket: UsageBucket,
|
||
}
|
||
|
||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||
pub struct UsageSummary {
|
||
pub rollup: UsageRollup,
|
||
pub success_rate: f64,
|
||
}
|
||
|
||
#[derive(Clone, Debug, PartialEq)]
|
||
pub struct CreateVersionRequest<'a> {
|
||
pub workspace_id: &'a WorkspaceId,
|
||
pub snapshot: &'a RegistryOperation,
|
||
pub change_note: Option<&'a str>,
|
||
pub created_by: Option<&'a str>,
|
||
}
|
||
|
||
#[derive(Clone, Debug, PartialEq, Eq)]
|
||
pub struct OperationStateExpectation {
|
||
pub current_draft_version: u32,
|
||
pub status: OperationStatus,
|
||
pub latest_published_version: Option<u32>,
|
||
}
|
||
|
||
#[derive(Clone, Debug, PartialEq, Eq)]
|
||
pub struct PublishRequest<'a> {
|
||
pub workspace_id: &'a WorkspaceId,
|
||
pub operation_id: &'a OperationId,
|
||
pub version: u32,
|
||
pub published_at: &'a OffsetDateTime,
|
||
pub published_by: Option<&'a str>,
|
||
}
|
||
|
||
#[derive(Clone, Debug, PartialEq, Eq)]
|
||
pub struct CreateYamlImportJobRequest<'a> {
|
||
pub id: &'a YamlImportJobId,
|
||
pub source_sample_id: Option<&'a SampleId>,
|
||
pub format_version: &'a str,
|
||
pub mode: ExportMode,
|
||
pub created_at: &'a OffsetDateTime,
|
||
}
|
||
|
||
#[derive(Clone, Debug, PartialEq, Eq)]
|
||
pub struct SaveAuthProfileRequest<'a> {
|
||
pub workspace_id: &'a WorkspaceId,
|
||
pub profile: &'a AuthProfile,
|
||
}
|
||
|
||
#[derive(Clone, Debug, PartialEq)]
|
||
pub struct SaveWorkspaceUpstreamRequest<'a> {
|
||
pub upstream: &'a WorkspaceUpstream,
|
||
}
|
||
|
||
#[derive(Clone, Debug, PartialEq)]
|
||
pub struct CreateWorkspaceRequest<'a> {
|
||
pub workspace: &'a Workspace,
|
||
}
|
||
|
||
#[derive(Clone, Debug, PartialEq)]
|
||
pub struct UpdateWorkspaceRequest<'a> {
|
||
pub workspace: &'a Workspace,
|
||
}
|
||
|
||
#[derive(Clone, Debug, PartialEq)]
|
||
pub struct CreateAgentRequest<'a> {
|
||
pub agent: &'a Agent,
|
||
pub version: &'a AgentVersion,
|
||
pub bindings: &'a [AgentOperationBinding],
|
||
}
|
||
|
||
#[derive(Clone, Debug, PartialEq)]
|
||
pub struct CreateAgentDraftVersionRequest<'a> {
|
||
pub workspace_id: &'a WorkspaceId,
|
||
pub agent_id: &'a AgentId,
|
||
pub version: &'a AgentVersion,
|
||
pub bindings: &'a [AgentOperationBinding],
|
||
pub updated_at: &'a OffsetDateTime,
|
||
}
|
||
|
||
#[derive(Clone, Debug, PartialEq)]
|
||
pub struct UpdateAgentSummaryRequest<'a> {
|
||
pub slug: &'a str,
|
||
pub display_name: &'a str,
|
||
pub description: &'a str,
|
||
pub updated_at: &'a OffsetDateTime,
|
||
pub expected_state: Option<&'a AgentStateExpectation>,
|
||
}
|
||
|
||
#[derive(Clone, Debug, PartialEq)]
|
||
pub struct SaveAgentBindingsRequest<'a> {
|
||
pub workspace_id: &'a WorkspaceId,
|
||
pub agent_id: &'a AgentId,
|
||
pub agent_version: u32,
|
||
pub bindings: &'a [AgentOperationBinding],
|
||
pub expected_state: Option<&'a AgentStateExpectation>,
|
||
}
|
||
|
||
#[derive(Clone, Debug, PartialEq)]
|
||
pub struct SaveAgentCatalogConfigRequest<'a> {
|
||
pub workspace_id: &'a WorkspaceId,
|
||
pub agent_id: &'a AgentId,
|
||
pub agent_version: u32,
|
||
pub bindings: &'a [AgentOperationBinding],
|
||
pub tool_selection_policy: &'a ToolSelectionPolicy,
|
||
/// Точный список Published Resource Versions для Draft-версии (Story 3.7 AC04).
|
||
pub resource_bindings: &'a [AgentResourceBinding],
|
||
pub expected_state: Option<&'a AgentStateExpectation>,
|
||
}
|
||
|
||
#[derive(Clone, Debug, PartialEq, Eq)]
|
||
pub struct PublishAgentRequest<'a> {
|
||
pub workspace_id: &'a WorkspaceId,
|
||
pub agent_id: &'a AgentId,
|
||
pub version: u32,
|
||
pub published_at: &'a OffsetDateTime,
|
||
pub published_by: Option<&'a str>,
|
||
pub expected_state: Option<&'a AgentStateExpectation>,
|
||
}
|
||
|
||
#[derive(Clone, Debug, PartialEq, Eq)]
|
||
pub struct CreateInvitationRequest<'a> {
|
||
pub invitation: &'a InvitationToken,
|
||
}
|
||
|
||
#[derive(Clone, Debug, PartialEq)]
|
||
pub struct CreatePlatformApiKeyRequest<'a> {
|
||
pub api_key: &'a PlatformApiKey,
|
||
pub secret_hash: &'a str,
|
||
}
|
||
|
||
#[derive(Clone, Debug)]
|
||
pub struct CreateApprovalRequest<'a> {
|
||
pub approval: &'a ApprovalRequest,
|
||
}
|
||
|
||
#[derive(Clone, Debug)]
|
||
pub struct ListApprovalRequestsQuery<'a> {
|
||
pub workspace_id: &'a WorkspaceId,
|
||
pub status: Option<ApprovalRequestStatus>,
|
||
pub limit: u32,
|
||
}
|
||
|
||
#[derive(Clone, Debug)]
|
||
pub struct DecideApprovalRequest<'a> {
|
||
pub workspace_id: &'a WorkspaceId,
|
||
pub agent_id: &'a AgentId,
|
||
pub approval_id: &'a ApprovalRequestId,
|
||
pub operation_id: &'a OperationId,
|
||
pub operation_version: u32,
|
||
pub request_payload: &'a Value,
|
||
pub status: ApprovalRequestStatus,
|
||
pub decided_at: OffsetDateTime,
|
||
pub decided_by_key_id: Option<&'a PlatformApiKeyId>,
|
||
pub response_payload: Option<Value>,
|
||
pub decision_note: Option<&'a str>,
|
||
}
|
||
|
||
#[derive(Clone, Debug)]
|
||
pub struct FinishApprovalRequest<'a> {
|
||
pub workspace_id: &'a WorkspaceId,
|
||
pub agent_id: &'a AgentId,
|
||
pub approval_id: &'a ApprovalRequestId,
|
||
pub status: ApprovalRequestStatus,
|
||
pub response_payload: Option<Value>,
|
||
pub decision_note: Option<&'a str>,
|
||
}
|
||
|
||
#[derive(Clone, Debug)]
|
||
pub struct ExpireApprovalRequest<'a> {
|
||
pub workspace_id: &'a WorkspaceId,
|
||
pub agent_id: &'a AgentId,
|
||
pub approval_id: &'a ApprovalRequestId,
|
||
pub expired_at: OffsetDateTime,
|
||
}
|
||
|
||
#[derive(Clone, Debug, PartialEq)]
|
||
pub struct CreateSecretRequest<'a> {
|
||
pub secret: &'a Secret,
|
||
pub ciphertext: &'a str,
|
||
pub key_version: &'a str,
|
||
pub master_key_epoch: i64,
|
||
pub created_by: Option<&'a crank_core::UserId>,
|
||
}
|
||
|
||
#[derive(Clone, Debug, PartialEq)]
|
||
pub struct RotateSecretRequest<'a> {
|
||
pub workspace_id: &'a WorkspaceId,
|
||
pub secret_id: &'a SecretId,
|
||
pub ciphertext: &'a str,
|
||
pub key_version: &'a str,
|
||
pub master_key_epoch: i64,
|
||
pub created_at: &'a OffsetDateTime,
|
||
pub updated_at: &'a OffsetDateTime,
|
||
pub created_by: Option<&'a crank_core::UserId>,
|
||
}
|
||
|
||
#[derive(Clone, Debug, PartialEq, Eq)]
|
||
pub struct SaveSampleMetadataRequest<'a> {
|
||
pub sample: &'a OperationSampleMetadata,
|
||
}
|
||
|
||
#[derive(Clone, Debug, PartialEq)]
|
||
pub struct SaveDescriptorMetadataRequest<'a> {
|
||
pub descriptor: &'a DescriptorMetadata,
|
||
}
|