Files
crank/crates/crank-registry/src/error.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

251 lines
12 KiB
Rust

use thiserror::Error;
#[derive(Debug, Error)]
pub enum RegistryError {
#[error(transparent)]
Migration(#[from] crate::migrations::MigrationError),
#[error(transparent)]
Storage(#[from] sqlx::Error),
#[error(transparent)]
Serialization(#[from] serde_json::Error),
#[error("workspace {workspace_id} was not found")]
WorkspaceNotFound { workspace_id: String },
#[error("workspace with slug {slug} already exists")]
WorkspaceSlugAlreadyExists { slug: String },
#[error("user {user_id} was not found")]
UserNotFound { user_id: String },
#[error("user with email {email} already exists")]
UserEmailAlreadyExists { email: String },
#[error("admin bootstrap contract is not available")]
AdminBootstrapUnavailable,
#[error("admin bootstrap contract is invalid, expired or already used")]
AdminBootstrapRejected,
#[error("admin recovery request is invalid or unavailable")]
AdminRecoveryRejected,
#[error("admin login is temporarily rate limited")]
AdminLoginRateLimited { retry_after_ms: i64 },
#[error("admin csrf token is invalid or missing")]
AdminCsrfRejected,
#[error("membership for user {user_id} in workspace {workspace_id} was not found")]
MembershipNotFound {
workspace_id: String,
user_id: String,
},
#[error("invitation {invitation_id} was not found")]
InvitationNotFound { invitation_id: String },
#[error("platform api key {key_id} was not found")]
PlatformApiKeyNotFound { key_id: String },
#[error("platform api key {key_id} is not active")]
PlatformApiKeyInactive { key_id: String },
#[error("platform api key with name {name} already exists in workspace {workspace_id}")]
PlatformApiKeyNameAlreadyExists { workspace_id: String, name: String },
#[error("secret {secret_id} was not found")]
SecretNotFound { secret_id: String },
#[error("secret {secret_id} is not active")]
SecretInactive { secret_id: String },
#[error("secret {secret_id} was updated concurrently")]
SecretConcurrentUpdate { secret_id: String },
#[error("master key identity is not compatible with registered epoch {epoch}")]
MasterKeyIdentityMismatch { epoch: i64 },
#[error("master key identity metadata is invalid")]
InvalidMasterKeyIdentity,
#[error("master key rotation is already active")]
MasterKeyRotationInProgress,
#[error("master key rotation {rotation_id} was not found")]
MasterKeyRotationNotFound { rotation_id: String },
#[error("master key rotation state is incompatible with requested transition")]
MasterKeyRotationConflict,
#[error("master key rotation verification failed")]
MasterKeyRotationVerificationFailed,
#[error("secret with name {name} already exists in workspace {workspace_id}")]
SecretNameAlreadyExists { workspace_id: String, name: String },
#[error("secret {secret_id} is referenced by auth profile {auth_profile_id}")]
SecretReferencedByAuthProfile {
secret_id: String,
auth_profile_id: String,
},
#[error("invocation log {log_id} was not found")]
InvocationLogNotFound { log_id: String },
#[error("agent {agent_id} was not found")]
AgentNotFound { agent_id: String },
#[error("published agent {workspace_slug}/{agent_slug} was not found")]
PublishedAgentNotFound {
workspace_slug: String,
agent_slug: String,
},
#[error("operation {operation_id} already exists")]
OperationAlreadyExists { operation_id: String },
#[error("operation {operation_id} was not found")]
OperationNotFound { operation_id: String },
#[error("operation version {version} for {operation_id} was not found")]
OperationVersionNotFound { operation_id: String, version: u32 },
#[error("operation {operation_id} cannot be deleted while it is bound to a published agent")]
OperationHasPublishedAgentBindings { operation_id: String },
#[error("operation {operation_id} must start with version 1, got {version}")]
InvalidInitialVersion { operation_id: String, version: u32 },
#[error("operation {operation_id} expected next version {expected}, got {actual}")]
InvalidVersionSequence {
operation_id: String,
expected: u32,
actual: u32,
},
#[error("operation {operation_id} is archived")]
OperationArchived { operation_id: String },
#[error("resource {resource_id} is archived and cannot receive new Agent bindings")]
ResourceArchived { resource_id: String },
#[error(
"resource {resource_id} is revoked and cannot receive new Agent bindings or publications"
)]
ResourceRevoked { resource_id: String },
#[error("operation {operation_id} has a stale base version: expected {expected}, got {actual}")]
OperationStaleVersion {
operation_id: String,
expected: u32,
actual: u32,
},
#[error("operation {operation_id} cannot transition from {from} using {action}")]
InvalidOperationTransition {
operation_id: String,
from: String,
action: &'static str,
},
#[error("operation {operation_id} cannot be deleted because durable history exists")]
OperationDeleteForbidden { operation_id: String },
#[error("operation {operation_id} auth profile reference is unavailable")]
OperationAuthProfileUnavailable { operation_id: String },
#[error("agent {agent_id} expected next version {expected}, got {actual}")]
InvalidAgentVersionSequence {
agent_id: String,
expected: u32,
actual: u32,
},
#[error("agent version {version} for {agent_id} is immutable")]
ImmutableAgentVersion { agent_id: String, version: u32 },
#[error("agent {agent_id} state changed before mutation")]
AgentStaleRevision { agent_id: String },
#[error("agent {agent_id} cannot transition from {from} using {action}")]
InvalidAgentTransition {
agent_id: String,
from: String,
action: &'static str,
},
#[error("operation {operation_id} changed immutable field {field}")]
ImmutableOperationFieldChanged {
operation_id: String,
field: &'static str,
},
#[error("auth profile {auth_profile_id} was not found")]
AuthProfileNotFound { auth_profile_id: String },
#[error("yaml import job {job_id} was not found")]
YamlImportJobNotFound { job_id: String },
#[error("import job {job_id} was not found")]
ImportJobNotFound { job_id: String },
#[error("import job {job_id} was already applied with different parameters")]
ImportJobAlreadyApplied { job_id: String },
#[error("invalid import plan input for field {field}")]
InvalidImportPlan { field: &'static str },
#[error("import plan {plan_id} already exists with different material")]
ImportPlanConflict { plan_id: String },
#[error("import job {job_id} is unavailable for planning in this workspace")]
ImportPlanJobUnavailable { job_id: String },
#[error("import job {job_id} is in a terminal state and cannot be planned")]
ImportPlanJobTerminal { job_id: String },
#[error("import job {job_id} has expired and cannot be planned")]
ImportPlanJobExpired { job_id: String },
#[error("import plan {plan_id} was not found in this workspace")]
ImportPlanNotFound { plan_id: String },
#[error("import plan {plan_id} has expired or its anchor job changed; create a fresh preview")]
ImportPlanExpired { plan_id: String },
#[error(
"import plan {plan_id} material is corrupt or no longer consistent; create a fresh preview"
)]
ImportPlanPayloadCorrupt { plan_id: String },
#[error(
"import plan {plan_id} no longer matches the revalidated preview; create a fresh preview"
)]
ImportPlanFingerprintStale { plan_id: String },
#[error(
"import plan idempotency key {idempotency_key} was already used with different plan material; create a fresh preview"
)]
ImportPlanKeyDigestConflict { idempotency_key: String },
#[error("operation with name {name} already exists; confirm skip, rename, or new version")]
ImportPlanNameConflict { name: String },
#[error("operation {operation_id} changed after the plan was created; create a fresh preview")]
ImportPlanTargetStale { operation_id: String },
#[error(
"import plan auth profile {auth_profile_id} is unavailable, revoked or mismatched; create a fresh preview"
)]
ImportPlanAuthUnavailable { auth_profile_id: String },
#[error("unsupported enum representation for field {field}")]
InvalidEnumRepresentation { field: &'static str },
#[error("invalid numeric value for field {field}: {value}")]
InvalidNumericValue { field: &'static str, value: i64 },
#[error("invalid correlation identity for field {field}")]
InvalidCorrelationIdentity { field: &'static str },
#[error("new invocation record is missing or has incompatible execution field {field}")]
InvalidExecutionRecord { field: &'static str },
#[error("onboarding state changed before presentation milestone mutation")]
OnboardingStaleRevision,
#[error("onboarding domain steps are not complete")]
OnboardingIncomplete,
#[error(
"onboarding import Draft is not an actionable Draft produced by a committed import apply"
)]
OnboardingImportDraftUnavailable,
#[error("no committed import apply report matches the requested application identity")]
OnboardingImportApplicationUnavailable,
#[error("the workspace has no durable import context matching the requested application")]
OnboardingImportContextUnavailable,
#[error("artifact source {source_id} was not found")]
SourceNotFound { source_id: String },
#[error("artifact source {source_id} conflicts with immutable metadata or lifecycle")]
SourceConflict { source_id: String },
#[error("artifact source is unavailable")]
SourceUnavailable,
#[error("artifact source integrity verification failed")]
SourceIntegrity,
#[error("artifact reconciliation is already claimed")]
ArtifactClaimInProgress,
#[error("artifact source metadata is invalid for field {field}")]
InvalidArtifactSource { field: &'static str },
#[error("prompt {prompt_id} was not found in this workspace")]
PromptNotFound { prompt_id: String },
#[error("prompt {prompt_id} is not in Draft state")]
PromptNotDraft { prompt_id: String },
#[error("prompt {prompt_id} changed since it was read")]
PromptStaleRevision { prompt_id: String },
#[error("prompt {prompt_id} version counter overflowed")]
PromptVersionOverflow { prompt_id: String },
#[error("prompt {prompt_id} has invalid stored data")]
PromptCorrupt { prompt_id: String },
#[error("prompt {prompt_id} is archived and cannot receive new bindings")]
PromptArchived { prompt_id: String },
#[error("published prompt version for {prompt_id} was not found in this workspace")]
PromptPublicationNotFound { prompt_id: String },
#[error("prompt {prompt_id} version is already published")]
PromptPublicationConflict { prompt_id: String },
#[error("prompt {prompt_id} dependency at position {position} cannot be resolved")]
PromptDependencyUnresolved {
prompt_id: String,
position: usize,
resource_id: String,
version: u32,
},
#[error("prompt {prompt_id} dependency at position {position} has no text representation")]
PromptDependencyRepresentationUnsupported {
prompt_id: String,
position: usize,
resource_id: String,
version: u32,
},
#[error("prompt {prompt_id} dependency at position {position} is not referenced by a message")]
PromptDependencyUnused {
prompt_id: String,
position: usize,
resource_id: String,
version: u32,
},
#[error("prompt {prompt_id} dependency at position {position} is unavailable")]
PromptDependencyUnavailable { prompt_id: String, position: usize },
}