feat: add safe artifact delete

This commit is contained in:
lda
2026-06-09 05:11:11 +07:00 Verified
parent 22f6dea601
commit a7b415a58a
17 changed files with 412 additions and 44 deletions
+26
View File
@@ -276,6 +276,32 @@ class WorkflowArtifactApi:
artifact = self._artifact_store().get_artifact(artifact_id, version)
return artifact.model_dump(mode="json")
async def delete_artifact(
self, *, artifact_id: str, version: int
) -> dict[str, Any]:
store = self._artifact_store()
blockers = store.deployments_for_artifact(artifact_id, version)
blocker_ids = [deployment.id for deployment in blockers]
if blocker_ids:
return {
"artifact_id": artifact_id,
"version": version,
"deleted": False,
"blocked_by_deployments": blocker_ids,
}
store.delete_artifact(artifact_id, version)
self.context.events.record_workflow_event(
"workflow_artifact_deleted",
capability_id=f"{artifact_id}@{version}",
payload={"artifact_id": artifact_id, "version": version},
)
return {
"artifact_id": artifact_id,
"version": version,
"deleted": True,
"blocked_by_deployments": [],
}
def _suggested_self_bindings(required_sources: Sequence[str]) -> dict[str, str]:
"""Suggest local bindings for built-in sources that deploy to themselves."""
+11
View File
@@ -95,6 +95,17 @@ class WorkflowApi:
version=version,
)
async def delete_artifact(
self,
*,
artifact_id: str,
version: int,
) -> dict[str, Any]:
return await self.artifacts.delete_artifact(
artifact_id=artifact_id,
version=version,
)
async def save_artifact(
self,
artifact: dict[str, Any],
+7
View File
@@ -137,6 +137,13 @@ class WorkflowArtifactSurface(Protocol):
version: int,
) -> dict[str, Any]: ...
async def delete_artifact(
self,
*,
artifact_id: str,
version: int,
) -> dict[str, Any]: ...
class WorkflowDeploymentSurface(Protocol):
"""Deployment methods exposed by workflow frontends."""