<span id="错误合同与环境校验"></span>

# Error contracts and environment validation

| Scenario ||
| --- | --- |
| Success | Numeric code 0 with data; do not reuse old OK/msg examples. |
| Tool referenced | When localization succeeds, DELETE returns 422/code 2/message with details.reason=TOOL_IN_USE and domain=moi-core.catalog.agent-resource. Localization failures return 500/code 1. |
| Skill referenced | When localization succeeds, DELETE returns 422/code 2/message with details.reason=SKILL_IN_USE and domain=moi-core.catalog.agent-resource. Localization failures return 500/code 1. |
| Parameter and unclassified errors | May return 400/code 2 with current error text; do not classify all as500. |
| Authentication failure | Identity checks before routing may return string code/msg, distinct from business numeric code/message. |

Deletion checks the current resource ID and workspace and examines bindings in nonarchived agent definitions and workspace overrides. Historical references retained in archived definitions are not active dependencies; overrides are still checked separately. This does not exhaustively establish every skill dependency on tools. Skill deletion DAO also deletes version and file records. External archive objects, backups, and historical run lifecycles require separate verification; removal of all copies is not guaranteed.
