AutoGPT is the vision of accessible AI for everyone, to use and to build on. Our mission is to provide the tools, so that you can focus on what matters.
fix(backend): enforce skill capacity at atomic root publication (#14793)
Nicholas Tindleb6b03f5e7249
diff --git a/autogpt_platform/backend/backend/api/features/experts/models.py b/autogpt_platform/backend/backend/api/features/experts/models.pyindex ecae5407b9..ca8d528851 100644--- a/autogpt_platform/backend/backend/api/features/experts/models.py+++ b/autogpt_platform/backend/backend/api/features/experts/models.py@@ -6,6 +6,7 @@ from urllib.parse import urlparsefrom pydantic import BaseModel, Field, TypeAdapter, ValidationError, field_validatorfrom backend.data.expert_run_output import OutputType+from backend.data.skill_capacity import MAX_SKILLS_PER_EXPERTExpertRunStatus = Literal["incomplete",@@ -420,10 +421,7 @@ class ExpertSkillsUpdate(BaseModel):expert must be library skills (default or uploaded); names already onthe expert are kept as-is so marketplace skills survive a round-trip."""- # As many names as the expert's folder can hold: MAX_SKILLS_PER_EXPERT in- # copilot/tools/skills.py, which this module cannot import (the copilot- # tools import these models); models_test pins the two together.- skills: list[str] = Field(max_length=150)+ skills: list[str] = Field(max_length=MAX_SKILLS_PER_EXPERT)# Store listing versions to attach as marketplace skills; each resolves# to the listing's public name, the same way the raise flow records them.marketplace_listing_ids: list[str] = Field(default_factory=list, max_length=20)diff --git a/autogpt_platform/backend/backend/api/features/workspace/routes.py b/autogpt_platform/backend/backend/api/features/workspace/routes.pyindex 69456fded4..9ce6eb0684 100644--- a/autogpt_platform/backend/backend/api/features/workspace/routes.py+++ b/autogpt_platform/backend/backend/api/features/workspace/routes.py@@ -20,6 +20,7 @@ from backend.api.features.store.exceptions import VirusDetectedError, VirusScanEfrom backend.api.features.workspace.preview import build_preview_responsefrom backend.copilot.db import get_chat_session_expert_idsfrom backend.copilot.rate_limit import get_workspace_storage_limit_bytes+from backend.data.skill_capacity import SkillLimitErrorfrom backend.data.workspace import (WorkspaceFile,count_workspace_files,@@ -282,7 +283,7 @@ async def delete_workspace_file(operation_id="renameWorkspaceFile",responses={404: {"description": "File not found"},- 409: {"description": "A file with this name already exists here"},+ 409: {"description": "File name conflict or skill capacity reached"},},)async def rename_workspace_file_route(@@ -300,6 +301,8 @@ async def rename_workspace_file_route(raise fastapi.HTTPException(status_code=409, detail="A file with this name already exists here")+ except SkillLimitError as exc:+ raise fastapi.HTTPException(status_code=409, detail=str(exc))if renamed is None:raise fastapi.HTTPException(status_code=404, detail="File not found")expert_by_session = await _expert_ids_by_session(user_id, [renamed])diff --git a/autogpt_platform/backend/backend/api/features/workspace/routes_test.py b/autogpt_platform/backend/backend/api/features/workspace/routes_test.pyindex a8b373ecbe..0035d883eb 100644--- a/autogpt_platform/backend/backend/api/features/workspace/routes_test.py+++ b/autogpt_platform/backend/backend/api/features/workspace/routes_test.py@@ -8,6 +8,7 @@ import pytestfrom prisma.errors import UniqueViolationErrorfrom backend.api.features.workspace.routes import router+from backend.data.skill_capacity import SkillLimitErrorfrom backend.data.workspace import Workspace, WorkspaceFilefrom backend.data.workspace_scope import WorkspaceScope@@ -1335,3 +1336,13 @@ def test_rename_file_rejects_bad_names(mock_get_workspace, mock_rename, name):response = client.patch("/files/f1", json={"name": name})assert response.status_code == 422mock_rename.assert_not_called()+++@patch("backend.api.features.workspace.routes.rename_workspace_file")+@patch("backend.api.features.workspace.routes.get_workspace")+def test_rename_file_reports_skill_capacity_conflict(mock_get_workspace, mock_rename):+ mock_get_workspace.return_value = _make_workspace()+ mock_rename.side_effect = SkillLimitError("Skill limit reached (150 saved skills).")+ response = client.patch("/files/f1", json={"name": "SKILL.md"})+ assert response.status_code == 409+ assert response.json()["detail"] == "Skill limit reached (150 saved skills)."diff --git a/autogpt_platform/backend/backend/copilot/tools/skills.py b/autogpt_platform/backend/backend/copilot/tools/skills.pyindex a855271068..bb4037c49a 100644--- a/autogpt_platform/backend/backend/copilot/tools/skills.py+++ b/autogpt_platform/backend/backend/copilot/tools/skills.py@@ -41,6 +41,14 @@ from backend.copilot.model import ChatSessionfrom backend.copilot.service import SKILLS_UPDATE_TAG, strip_server_injected_tagsfrom backend.data.db_accessors import experts_db, workspace_dbfrom backend.data.redis_client import get_redis_async+from backend.data.skill_capacity import MAX_SKILLS_PER_EXPERT+from backend.data.skill_capacity import SKILL_ORIGIN_LABELS as _ORIGIN_LABELS+from backend.data.skill_capacity import SKILL_ORIGIN_MARKETPLACE+from backend.data.skill_capacity import SKILL_ORIGIN_METADATA_KEY as _META_SKILL_ORIGIN+from backend.data.skill_capacity import SKILL_ORIGIN_USER+from backend.data.skill_capacity import SKILL_ORIGINS as _SKILL_ORIGINS+from backend.data.skill_capacity import SkillLimitError, SkillOwnedError+from backend.data.skill_capacity import normalize_skill_origin as _normalize_originfrom backend.data.workspace_scope import (EXPERT_SKILL_SCOPE_DENIED,WorkspaceAccessDeniedError,@@ -78,7 +86,6 @@ logger = logging.getLogger(__name__)# Built-in seeded skills are tiny so first-touch users see well under# 200 tokens of overhead.# ----------------------------------------------------------------------------MAX_SKILLS_PER_EXPERT = 150MAX_NAME_CHARS = 64MAX_DESCRIPTION_CHARS = 1024# Loaded only on activation, so it costs nothing per turn; 50k clears@@ -150,13 +157,8 @@ _META_EXECUTABLE = "executable"# Where a skill in an owner's folder came from. Kept in the row's metadata# (server-written; the frontmatter is the author's to edit) so the per-owner# cap counts what the owner saved apart from what the platform installed.-_META_SKILL_ORIGIN = "skill_origin"-SKILL_ORIGIN_USER = "user"-SKILL_ORIGIN_MARKETPLACE = "marketplace"# The built-in defaults: never stored, never counted, so not a storable origin.SKILL_ORIGIN_PLATFORM = "platform"-_SKILL_ORIGINS = frozenset({SKILL_ORIGIN_USER, SKILL_ORIGIN_MARKETPLACE})-_ORIGIN_LABELS = {SKILL_ORIGIN_USER: "saved", SKILL_ORIGIN_MARKETPLACE: "installed"}# Skill names are slug-like — lowercase letters, digits, dashes, underscores.# Must start and end with [a-z0-9] (no trailing/leading punctuation) so the@@ -410,12 +412,8 @@ async def resolve_skill_owner(return SkillOwner(expert_id=expert.id, scope=None)-# Redis lock key for serialising store_skill writes per user. A per-user-# distributed lock turns the otherwise-racy "count existing skills, then-# write a new one" into an atomic critical section so two concurrent-# ``store_skill`` calls cannot both pass the MAX_SKILLS_PER_EXPERT check.-# Held only for the duration of the count + write; skill reads stay-# lock-free.+# Best-effort package-write coordination. Root publication enforces capacity+# in PostgreSQL independently of this lease or the cached skill index._SKILL_WRITE_LOCK_KEY_PREFIX = "copilot:skill_write:"_SKILL_WRITE_LOCK_TTL_SECONDS = 30@@ -584,16 +582,6 @@ class BuiltInSkillError(Exception):"""Raised by :func:`delete_user_skill` for default seeded skills."""-class SkillLimitError(Exception):- """Raised by :func:`store_user_skill` when the owner's cap for skills of- that origin is reached."""---class SkillOwnedError(Exception):- """Raised by :func:`store_user_skill` when a platform install would- replace a skill the owner saved under that name."""--async def delete_user_skill(user_id: str,name: str,@@ -759,14 +747,7 @@ async def store_user_skill(# breaks a cap leaves the stored skill exactly as it was.validate_package(SkillPackage(skill_md=rendered, files=files))- # Serialise the count-then-write critical section per-user so two- # concurrent writers cannot both pass the MAX_SKILLS_PER_EXPERT check.- # ``AsyncClusterLock.try_acquire`` is non-blocking, so poll for up to- # ~1s before falling back to the strict-cap unlocked path below — without- # the wait, two near-simultaneous calls at MAX-1 both proceed unlocked,- # both see N<MAX, and both write (cap overruns by 1). Lock failure- # (Redis unavailable) still falls back to the unlocked write but the- # cap-enforcement branch below refuses any at-cap write in that case.+ # Coordinate ordinary package writes; the database owns the hard cap.lock: AsyncClusterLock | None = Nonelock_held = Falsetry:@@ -790,19 +771,7 @@ async def store_user_skill()try:manager = await _get_user_skill_manager(user_id, scope)- # Enforce the per-owner cap *before* we write. When the lock IS held- # this is a true atomic check-then-write — an upsert at-cap is safe- # because no new slot is consumed. When the lock FAILED to acquire,- # the check is no longer atomic, so refuse any write at-or-above the- # cap defensively (the caller can retry; a Redis blip is rare).- # No healing here: this call runs inside the per-owner write lock that- # the copy would need, so it would stall on itself for every name.- existing = await list_user_skills(user_id, expert_id, scope, heal_missing=False)- # One budget per origin: only skills of this origin fill this one,- # and only a name new to it takes a slot. A re-install of a bundled- # skill, or a rewrite of the owner's own, consumes nothing. The- # owner may take over a bundled name (it becomes theirs); the- # platform never replaces something the owner wrote.+ existing = await _list_user_skills_from_workspace(user_id, expert_id, scope)same_origin = {s.name for s in existing if budget_origin(s) == origin}if origin == SKILL_ORIGIN_MARKETPLACE and any(s.name == name and s.origin == SKILL_ORIGIN_USER for s in existing@@ -813,15 +782,7 @@ async def store_user_skill()at_cap = len(same_origin) >= MAX_SKILLS_PER_EXPERTis_new = name not in same_origin- if at_cap and (is_new or not lock_held):- if not lock_held:- logger.warning(- "[skills] refusing at-cap unlocked write for user %s "- "(is_new=%s) — concurrent write could otherwise overrun "- "the cap",- user_id,- is_new,- )+ if at_cap and is_new:raise SkillLimitError(f"Skill limit reached ({MAX_SKILLS_PER_EXPERT} {_ORIGIN_LABELS[origin]} ""skills). Delete an unused skill first."@@ -861,20 +822,20 @@ async def store_user_skill({_META_EXECUTABLE: True} if entry.is_executable else None),)+ await manager.write_file(+ content=rendered.encode("utf-8"),+ filename="SKILL.md",+ path=_skill_md_path(name, expert_id),+ mime_type="text/markdown",+ overwrite=True,+ metadata=metadata,+ )except Exception:# Not a rollback: a file already here keeps the new bytes, so an# upsert can fail mixed. Undo only what this call created — deleting# the rest would turn a failed write into a lost file.await _delete_paths(manager, written - existing_paths)raise- await manager.write_file(- content=rendered.encode("utf-8"),- filename="SKILL.md",- path=_skill_md_path(name, expert_id),- mime_type="text/markdown",- overwrite=True,- metadata=metadata,- )await _delete_paths(manager, {f.path for f in stale if f.path not in written}, stale)@@ -968,10 +929,6 @@ def _skill_origin(meta: Mapping[str, Any]) -> str | None:return _normalize_origin(meta.get(_META_SKILL_ORIGIN))-def _normalize_origin(value: object) -> str | None:- return value if isinstance(value, str) and value in _SKILL_ORIGINS else None--async def _list_user_skills_from_workspace(user_id: str,expert_id: str | None = None,diff --git a/autogpt_platform/backend/backend/copilot/tools/skills_test.py b/autogpt_platform/backend/backend/copilot/tools/skills_test.pyindex 3b9989a86e..f0270567d3 100644--- a/autogpt_platform/backend/backend/copilot/tools/skills_test.py+++ b/autogpt_platform/backend/backend/copilot/tools/skills_test.py@@ -757,11 +757,13 @@ def test_default_skills_are_platform_origin_not_the_owners():@pytest.mark.asyncioasync def test_store_user_skill_rejects_an_unknown_origin():- with _patch_skills_path(_FakeWorkspaceManager()):- with pytest.raises(ValueError, match="origin"):- await store_user_skill(- "user-1", name="x", description="ok", body="ok", origin="platform"- )+ with (+ _patch_skills_path(_FakeWorkspaceManager()),+ pytest.raises(ValueError, match="origin"),+ ):+ await store_user_skill(+ "user-1", name="x", description="ok", body="ok", origin="platform"+ )@pytest.mark.asyncio@@ -834,12 +836,27 @@ async def test_origin_survives_the_index_cache():@pytest.mark.asyncio-async def test_store_skill_at_cap_refuses_when_lock_not_held():- """When ``AsyncClusterLock.try_acquire`` returns a DIFFERENT owner- (i.e. contention or Redis hiccup) the fallback path is unlocked.- In that branch the cap check must be treated strictly — refuse the- write at-or-above MAX_SKILLS_PER_EXPERT even on an upsert, otherwise two- concurrent writers could both see N==cap and both commit."""+async def test_stale_empty_skill_index_cannot_bypass_capacity_preflight():+ fake = _FakeWorkspaceManager()+ for i in range(MAX_SKILLS_PER_EXPERT):+ fake.files[f"/skills/skill_{i}/SKILL.md"] = render_skill_markdown(+ ParsedSkill(name=f"skill_{i}", description="desc", body="body")+ ).encode()+ with (+ _patch_skills_path(fake),+ patch(+ "backend.copilot.tools.skills._read_skills_cache",+ AsyncMock(return_value=[]),+ ),+ ):+ with pytest.raises(SkillLimitError):+ await store_user_skill("user-1", name="extra", description="d", body="b")+ assert len(fake.files) == MAX_SKILLS_PER_EXPERT+++async def test_store_skill_at_cap_allows_upsert_without_redis_lock():+ """Root publication owns capacity even when Redis cannot coordinate writes."""tool = StoreSkillTool()fake_manager = _FakeWorkspaceManager()for i in range(MAX_SKILLS_PER_EXPERT):@@ -875,8 +892,7 @@ async def test_store_skill_at_cap_refuses_when_lock_not_held():description="ok",body="ok",)- # Upsert at-cap → also rejected in unlocked branch (cannot prove- # atomicity, so refuse defensively).+ # Updating an existing root does not consume capacity.upsert_result = await tool._execute(user_id="user-1",session=_make_session(),@@ -886,8 +902,7 @@ async def test_store_skill_at_cap_refuses_when_lock_not_held():)assert isinstance(new_result, ErrorResponse)assert "limit" in new_result.message.lower()- assert isinstance(upsert_result, ErrorResponse)- assert "limit" in upsert_result.message.lower()+ assert isinstance(upsert_result, StoreSkillResponse)@pytest.mark.asyncio@@ -2262,6 +2277,23 @@ async def test_a_failed_file_write_leaves_no_skill_and_no_tree():assert fake.files == {}+async def test_a_rejected_root_publication_removes_new_package_files():+ fake = _FailingWorkspaceManager(fail_on=3)+ with _patch_skills_path(fake):+ with pytest.raises(RuntimeError, match="storage unavailable"):+ await store_user_skill(+ "user-1",+ name="pkg",+ description="d",+ body="b",+ files=[+ SkillFile(relative_path=f"r{i}.md", content=b"x") for i in range(2)+ ],+ )+ assert fake.files == {}++@pytest.mark.asyncioasync def test_a_failed_re_store_undoes_only_what_it_wrote():"""The rollback deletes what this call created, never what was alreadydiff --git a/autogpt_platform/backend/backend/data/db_accessors.py b/autogpt_platform/backend/backend/data/db_accessors.pyindex b2603e87b8..c71578eb5d 100644--- a/autogpt_platform/backend/backend/data/db_accessors.py+++ b/autogpt_platform/backend/backend/data/db_accessors.py@@ -157,6 +157,16 @@ def workspace_db():return workspace_db+def workspace_skill_db():+ if db.is_connected():+ from backend.data import workspace_skill++ return workspace_skill+ from backend.util.clients import get_database_manager_async_client++ return get_database_manager_async_client()++def review_db():if db.is_connected():from backend.data import human_review as _review_dbdiff --git a/autogpt_platform/backend/backend/data/db_manager.py b/autogpt_platform/backend/backend/data/db_manager.pyindex e15758605e..9fb18e53b9 100644--- a/autogpt_platform/backend/backend/data/db_manager.py+++ b/autogpt_platform/backend/backend/data/db_manager.py@@ -189,6 +189,7 @@ from backend.data.workspace import (resolve_expert_workspace_scope,soft_delete_workspace_file,)+from backend.data.workspace_skill import publish_workspace_skill_filefrom backend.platform_linking import db as platform_linking_dbfrom backend.util.service import (AppService,@@ -446,6 +447,7 @@ class DatabaseManager(AppService):# ============ Workspace ============ #count_workspace_files = _(count_workspace_files)create_workspace_file = _(create_workspace_file)+ publish_workspace_skill_file = _(publish_workspace_skill_file)get_or_create_workspace = _(get_or_create_workspace)get_workspace_file = _(get_workspace_file)get_workspace_file_by_path = _(get_workspace_file_by_path)@@ -864,6 +866,7 @@ class DatabaseManagerAsyncClient(AppServiceClient):# ============ Workspace ============ #count_workspace_files = d.count_workspace_filescreate_workspace_file = d.create_workspace_file+ publish_workspace_skill_file = d.publish_workspace_skill_fileget_or_create_workspace = d.get_or_create_workspaceget_workspace_file = d.get_workspace_fileget_workspace_file_by_path = d.get_workspace_file_by_pathdiff --git a/autogpt_platform/backend/backend/data/skill_capacity.py b/autogpt_platform/backend/backend/data/skill_capacity.pynew file mode 100644index 0000000000..6e2a563e49--- /dev/null+++ b/autogpt_platform/backend/backend/data/skill_capacity.py@@ -0,0 +1,34 @@+import re++MAX_SKILLS_PER_EXPERT = 150+SKILL_ORIGIN_USER = "user"+SKILL_ORIGIN_MARKETPLACE = "marketplace"+SKILL_ORIGINS = frozenset({SKILL_ORIGIN_USER, SKILL_ORIGIN_MARKETPLACE})+SKILL_ORIGIN_LABELS = {+ SKILL_ORIGIN_USER: "saved",+ SKILL_ORIGIN_MARKETPLACE: "installed",+}+SKILL_ORIGIN_METADATA_KEY = "skill_origin"++_ROOT_PATH = re.compile(r"^(/skills|/experts/[^/]+/skills)/[^/]+/SKILL\.md$")+++class SkillLimitError(Exception):+ """The skill owner's published roots have reached capacity."""+++class SkillOwnedError(Exception):+ """A platform install would replace a skill saved by its owner."""+++def normalize_skill_origin(value: object) -> str | None:+ return value if isinstance(value, str) and value in SKILL_ORIGINS else None+++def skill_origin(metadata: dict | None) -> str | None:+ return normalize_skill_origin((metadata or {}).get(SKILL_ORIGIN_METADATA_KEY))+++def skill_owner_folder(path: str) -> str | None:+ match = _ROOT_PATH.fullmatch(path)+ return match.group(1) if match else Nonediff --git a/autogpt_platform/backend/backend/data/workspace.py b/autogpt_platform/backend/backend/data/workspace.pyindex b3ecf5dd94..9d9355c102 100644--- a/autogpt_platform/backend/backend/data/workspace.py+++ b/autogpt_platform/backend/backend/data/workspace.py@@ -15,6 +15,7 @@ from prisma.errors import UniqueViolationErrorfrom prisma.models import UserWorkspace, UserWorkspaceFilefrom prisma.types import UserWorkspaceFileWhereInput+from backend.data.skill_capacity import skill_owner_folderfrom backend.data.workspace_scope import (WorkspaceAccessDeniedError,resolve_expert_workspace_scope,@@ -408,6 +409,13 @@ async def rename_workspace_file(file = await get_workspace_file(file_id, workspace_id)if file is None:return None+ folder = skill_owner_folder(+ posixpath.join(posixpath.dirname(file.path), "SKILL.md")+ )+ if folder is not None:+ from backend.data.workspace_skill import rename_workspace_skill_file++ return await rename_workspace_skill_file(file_id, workspace_id, name, folder)new_path = posixpath.join(posixpath.dirname(file.path), name)updated = await UserWorkspaceFile.prisma().update(where={"id": file_id},diff --git a/autogpt_platform/backend/backend/data/workspace_skill.py b/autogpt_platform/backend/backend/data/workspace_skill.pynew file mode 100644index 0000000000..7957d818bf--- /dev/null+++ b/autogpt_platform/backend/backend/data/workspace_skill.py@@ -0,0 +1,179 @@+import posixpath+import re+from collections.abc import AsyncIterator+from contextlib import asynccontextmanager+from datetime import datetime, timezone+from typing import Literal++from prisma import Prisma+from prisma.models import UserWorkspaceFile+from pydantic import BaseModel++from backend.data.db import transaction+from backend.data.skill_capacity import (+ MAX_SKILLS_PER_EXPERT,+ SKILL_ORIGIN_LABELS,+ SKILL_ORIGIN_MARKETPLACE,+ SKILL_ORIGIN_METADATA_KEY,+ SKILL_ORIGIN_USER,+ SkillLimitError,+ skill_origin,+ skill_owner_folder,+)+from backend.data.workspace import WorkspaceFile+from backend.util.json import SafeJson+++class WorkspaceSkillWrite(BaseModel):+ workspace_id: str+ file_id: str+ name: str+ path: str+ storage_path: str+ mime_type: str+ size_bytes: int+ overwrite: bool+ checksum: str | None = None+ metadata: dict | None = None+++class WorkspaceSkillPublication(BaseModel):+ status: Literal["stored", "capacity", "exists", "owned"]+ file: WorkspaceFile | None = None+ replaced_storage_path: str | None = None+ replaced_file_id: str | None = None+++async def publish_workspace_skill_file(+ write: WorkspaceSkillWrite,+) -> WorkspaceSkillPublication:+ folder = skill_owner_folder(write.path)+ if folder is None:+ raise ValueError("Skill publication requires a canonical SKILL.md path")+ async with _publication_transaction(write.workspace_id, folder) as tx:+ existing = await tx.userworkspacefile.find_unique(+ where={+ "workspaceId_path": {+ "workspaceId": write.workspace_id,+ "path": write.path,+ }+ }+ )+ if existing and not existing.isDeleted and not write.overwrite:+ return WorkspaceSkillPublication(status="exists")+ origin = skill_origin(write.metadata) or SKILL_ORIGIN_USER+ existing_origin = skill_origin(+ existing.metadata+ if existing and isinstance(existing.metadata, dict)+ else None+ )+ active = existing is not None and not existing.isDeleted+ if (+ active+ and origin == SKILL_ORIGIN_MARKETPLACE+ and existing_origin == SKILL_ORIGIN_USER+ ):+ return WorkspaceSkillPublication(status="owned")+ if (not active or (existing_origin or SKILL_ORIGIN_USER) != origin) and (+ await _root_count(tx, write.workspace_id, folder, origin)+ >= MAX_SKILLS_PER_EXPERT+ ):+ return WorkspaceSkillPublication(status="capacity")+ record = (+ await _replace_root(tx, existing.id, write)+ if existing+ else await _create_root(tx, write)+ )+ return WorkspaceSkillPublication(+ status="stored",+ file=WorkspaceFile.from_db(record),+ replaced_storage_path=existing.storagePath if existing else None,+ replaced_file_id=existing.id if existing else None,+ )+++@asynccontextmanager+async def _publication_transaction(+ workspace_id: str, folder: str+) -> AsyncIterator[Prisma]:+ async with transaction() as tx:+ await tx.execute_raw("SET TRANSACTION ISOLATION LEVEL READ COMMITTED")+ await tx.execute_raw(+ "SELECT pg_advisory_xact_lock(hashtextextended($1, 0))",+ f"skill-capacity:{workspace_id}:{folder}",+ )+ yield tx+++async def rename_workspace_skill_file(+ file_id: str, workspace_id: str, name: str, folder: str+) -> WorkspaceFile | None:+ async with _publication_transaction(workspace_id, folder) as tx:+ file = await tx.userworkspacefile.find_first(+ where={"id": file_id, "workspaceId": workspace_id, "isDeleted": False}+ )+ if file is None:+ return None+ new_path = posixpath.join(posixpath.dirname(file.path), name)+ if skill_owner_folder(new_path) and not skill_owner_folder(file.path):+ origin = (+ skill_origin(file.metadata if isinstance(file.metadata, dict) else None)+ or SKILL_ORIGIN_USER+ )+ if (+ await _root_count(tx, workspace_id, folder, origin)+ >= MAX_SKILLS_PER_EXPERT+ ):+ raise SkillLimitError(+ f"Skill limit reached ({MAX_SKILLS_PER_EXPERT} {SKILL_ORIGIN_LABELS[origin]} "+ "skills). Delete an unused skill first."+ )+ updated = await tx.userworkspacefile.update(+ where={"id": file_id}, data={"name": name, "path": new_path}+ )+ return WorkspaceFile.from_db(updated) if updated else None+++async def _root_count(tx: Prisma, workspace_id: str, folder: str, origin: str) -> int:+ rows = await tx.query_raw(+ 'SELECT COUNT(*)::int AS count FROM "UserWorkspaceFile" '+ 'WHERE "workspaceId" = $1 AND NOT "isDeleted" AND path ~ $2 '+ "AND CASE WHEN metadata->>$3 = $4 THEN $4 ELSE $5 END = $6",+ workspace_id,+ rf"^{re.escape(folder)}/[^/]+/SKILL\.md$",+ SKILL_ORIGIN_METADATA_KEY,+ SKILL_ORIGIN_MARKETPLACE,+ SKILL_ORIGIN_USER,+ origin,+ )+ return rows[0]["count"]+++async def _create_root(tx: Prisma, write: WorkspaceSkillWrite) -> UserWorkspaceFile:+ return await tx.userworkspacefile.create(+ data={+ "id": write.file_id,+ "workspaceId": write.workspace_id,+ "name": write.name,+ "path": write.path,+ "storagePath": write.storage_path,+ "mimeType": write.mime_type,+ "sizeBytes": write.size_bytes,+ "checksum": write.checksum,+ "metadata": SafeJson(write.metadata or {}),+ }+ )+++async def _replace_root(+ tx: Prisma, file_id: str, write: WorkspaceSkillWrite+) -> UserWorkspaceFile:+ await tx.userworkspacefile.update(+ where={"id": file_id},+ data={+ "isDeleted": True,+ "deletedAt": datetime.now(timezone.utc),+ "path": f"{write.path}__deleted__{file_id}",+ },+ )+ return await _create_root(tx, write)diff --git a/autogpt_platform/backend/backend/data/workspace_skill_test.py b/autogpt_platform/backend/backend/data/workspace_skill_test.pynew file mode 100644index 0000000000..0f05644a23--- /dev/null+++ b/autogpt_platform/backend/backend/data/workspace_skill_test.py@@ -0,0 +1,404 @@+import asyncio+import uuid+from collections.abc import AsyncIterator+from contextlib import asynccontextmanager, nullcontext+from pathlib import Path+from unittest.mock import AsyncMock, patch++import pytest+import pytest_asyncio+from prisma import Json+from prisma.errors import UniqueViolationError++from backend.data import db+from backend.data.skill_capacity import MAX_SKILLS_PER_EXPERT, SkillLimitError+from backend.data.workspace import WorkspaceFile, rename_workspace_file+from backend.data.workspace_skill import (+ WorkspaceSkillWrite,+ publish_workspace_skill_file,+)+from backend.util.workspace import WorkspaceManager+from backend.util.workspace_storage import LocalWorkspaceStorage+++@pytest_asyncio.fixture(loop_scope="session")+async def workspace_id() -> AsyncIterator[str]:+ owned_connection = not db.is_connected()+ if owned_connection:+ await db.connect()+ user_id = str(uuid.uuid4())+ await db.prisma.user.create(+ data={"id": user_id, "email": f"capacity-{user_id}@example.com"}+ )+ workspace = await db.prisma.userworkspace.create(data={"userId": user_id})+ try:+ yield workspace.id+ finally:+ await db.prisma.user.delete(where={"id": user_id})+ if owned_connection:+ await db.disconnect()+++def write(+ workspace_id: str, slug: str, folder: str = "/skills", overwrite: bool = True+):+ file_id = str(uuid.uuid4())+ return WorkspaceSkillWrite(+ workspace_id=workspace_id,+ file_id=file_id,+ name="SKILL.md",+ path=f"{folder}/{slug}/SKILL.md",+ storage_path=f"test://{file_id}",+ mime_type="text/markdown",+ size_bytes=20,+ overwrite=overwrite,+ metadata={"kind": "copilot_skill", "description": "test"},+ )+++async def seed(+ workspace_id: str, count: int, folder: str = "/skills", origin: str | None = None+):+ await db.prisma.userworkspacefile.create_many(+ data=[+ {+ "workspaceId": workspace_id,+ "name": "SKILL.md",+ "path": f"{folder}/skill-{i}/SKILL.md",+ "storagePath": f"test://{i}",+ "mimeType": "text/markdown",+ "sizeBytes": 20,+ "metadata": Json({"skill_origin": origin} if origin else {}),+ }+ for i in range(count)+ ]+ )+++@asynccontextmanager+async def initially_repeatable_read_transaction():+ async with db.transaction() as tx:+ await tx.execute_raw("SET TRANSACTION ISOLATION LEVEL REPEATABLE READ")+ yield tx++[email protected](loop_scope="session")[email protected]("initially_repeatable_read", [False, True])[email protected]("origin", ["user", "marketplace"])+async def test_concurrent_new_roots_cannot_both_take_last_slot(+ workspace_id: str, initially_repeatable_read: bool, origin: str+):+ await seed(workspace_id, MAX_SKILLS_PER_EXPERT - 1, origin=origin)+ with (+ patch(+ "backend.data.workspace_skill.transaction",+ initially_repeatable_read_transaction,+ )+ if initially_repeatable_read+ else nullcontext()+ ):+ results = await asyncio.gather(+ *(+ publish_workspace_skill_file(+ write(workspace_id, f"new-{i}").model_copy(+ update={"metadata": {"skill_origin": origin}}+ )+ )+ for i in range(8)+ )+ )+ assert sum(result.status == "stored" for result in results) == 1+ assert sum(result.status == "capacity" for result in results) == 7+ assert (+ await db.prisma.userworkspacefile.count(+ where={"workspaceId": workspace_id, "isDeleted": False}+ )+ == MAX_SKILLS_PER_EXPERT+ )++[email protected](loop_scope="session")+async def test_upserts_at_capacity_never_expose_a_free_slot(workspace_id: str):+ await seed(workspace_id, MAX_SKILLS_PER_EXPERT)+ existing = await db.prisma.userworkspacefile.find_unique(+ where={+ "workspaceId_path": {+ "workspaceId": workspace_id,+ "path": "/skills/skill-0/SKILL.md",+ }+ }+ )+ assert existing is not None+ replacement = write(workspace_id, "skill-0")+ replaced, rejected = await asyncio.gather(+ publish_workspace_skill_file(replacement),+ publish_workspace_skill_file(write(workspace_id, "extra")),+ )+ assert replaced.status == "stored"+ assert replaced.file is not None+ assert replaced.file.id == replacement.file_id+ assert replaced.file.id != existing.id+ retired = await db.prisma.userworkspacefile.find_unique(where={"id": existing.id})+ assert retired is not None and retired.isDeleted+ assert replaced.file.storage_path == replacement.storage_path+ assert replaced.replaced_storage_path == existing.storagePath+ assert rejected.status == "capacity"+ assert (+ await db.prisma.userworkspacefile.count(+ where={"workspaceId": workspace_id, "isDeleted": False}+ )+ == MAX_SKILLS_PER_EXPERT+ )++[email protected](loop_scope="session")+async def test_personal_and_expert_folders_have_independent_capacity(workspace_id: str):+ await seed(workspace_id, MAX_SKILLS_PER_EXPERT)+ first, second = await asyncio.gather(+ publish_workspace_skill_file(+ write(workspace_id, "same-name", "/experts/first/skills")+ ),+ publish_workspace_skill_file(+ write(workspace_id, "same-name", "/experts/second/skills")+ ),+ )+ assert first.status == second.status == "stored"++[email protected](loop_scope="session")+async def test_another_users_workspace_has_independent_capacity(workspace_id: str):+ await seed(workspace_id, MAX_SKILLS_PER_EXPERT)+ other_user = str(uuid.uuid4())+ await db.prisma.user.create(+ data={"id": other_user, "email": f"capacity-{other_user}@example.com"}+ )+ try:+ other_workspace = await db.prisma.userworkspace.create(+ data={"userId": other_user}+ )+ result = await publish_workspace_skill_file(write(other_workspace.id, "first"))+ assert result.status == "stored"+ assert result.file is not None+ assert result.file.workspace_id == other_workspace.id+ finally:+ await db.prisma.user.delete(where={"id": other_user})++[email protected](loop_scope="session")+async def test_non_overwrite_rejection_preserves_root(workspace_id: str):+ original = await publish_workspace_skill_file(write(workspace_id, "same"))+ rejected = await publish_workspace_skill_file(+ write(workspace_id, "same", overwrite=False)+ )+ assert original.file is not None+ assert rejected.status == "exists"+ row = await db.prisma.userworkspacefile.find_unique(where={"id": original.file.id})+ assert row is not None+ assert row.storagePath == original.file.storage_path++[email protected](loop_scope="session")+async def test_failed_replacement_rolls_back_root_retirement(workspace_id: str):+ original = await publish_workspace_skill_file(write(workspace_id, "original"))+ other = await publish_workspace_skill_file(write(workspace_id, "other"))+ assert original.file is not None and other.file is not None+ replacement = write(workspace_id, "original").model_copy(+ update={"file_id": other.file.id}+ )+ with pytest.raises(UniqueViolationError):+ await publish_workspace_skill_file(replacement)+ row = await db.prisma.userworkspacefile.find_unique(where={"id": original.file.id})+ assert row is not None+ assert not row.isDeleted+ assert row.path == original.file.path+ assert row.storagePath == original.file.storage_path++[email protected](loop_scope="session")+async def test_nested_skill_files_and_deleted_roots_do_not_consume_slots(+ workspace_id: str,+):+ await seed(workspace_id, MAX_SKILLS_PER_EXPERT - 1)+ await db.prisma.userworkspacefile.create(+ data={+ "workspaceId": workspace_id,+ "name": "SKILL.md",+ "path": "/skills/skill-0/references/SKILL.md",+ "storagePath": "test://nested",+ "mimeType": "text/markdown",+ "sizeBytes": 1,+ }+ )+ await db.prisma.userworkspacefile.create(+ data={+ "workspaceId": workspace_id,+ "name": "SKILL.md",+ "path": "/skills/deleted/SKILL.md",+ "storagePath": "test://deleted",+ "mimeType": "text/markdown",+ "sizeBytes": 1,+ "isDeleted": True,+ }+ )+ result = await publish_workspace_skill_file(write(workspace_id, "last"))+ assert result.status == "stored"++[email protected](loop_scope="session")+async def test_manager_publishes_and_replaces_real_files_at_capacity(+ workspace_id: str, tmp_path: Path+):+ workspace = await db.prisma.userworkspace.find_unique(where={"id": workspace_id})+ assert workspace is not None+ manager = WorkspaceManager(workspace.userId, workspace_id)+ storage = LocalWorkspaceStorage(base_dir=str(tmp_path))+ with (+ patch(+ "backend.util.workspace.get_workspace_storage",+ AsyncMock(return_value=storage),+ ),+ patch(+ "backend.util.workspace.get_workspace_storage_limit_bytes",+ AsyncMock(return_value=1_000_000),+ ),+ patch("backend.util.workspace.scan_content_safe", AsyncMock()),+ patch(+ "backend.api.features.workspace.embeddings.schedule_workspace_file_embedding"+ ),+ ):+ original = await manager.write_file(+ b"old", "SKILL.md", path="/skills/existing/SKILL.md", overwrite=True+ )+ await seed(workspace_id, MAX_SKILLS_PER_EXPERT - 1)+ with pytest.raises(SkillLimitError):+ await manager.write_file(+ b"extra", "SKILL.md", path="/skills/extra/SKILL.md", overwrite=True+ )+ assert len(list(tmp_path.rglob("SKILL.md"))) == 1+ replacement = await manager.write_file(+ b"new", "SKILL.md", path="/skills/existing/SKILL.md", overwrite=True+ )+ assert replacement.id != original.id+ assert await manager.read_file_by_id(replacement.id) == b"new"+ with pytest.raises(FileNotFoundError):+ await manager.read_file_by_id(original.id)+ assert len(list(tmp_path.rglob("SKILL.md"))) == 1++[email protected](loop_scope="session")+ "full_origin,other_origin", [("user", "marketplace"), ("marketplace", "user")]+)+async def test_saved_and_installed_budgets_are_independent(+ workspace_id: str, full_origin: str, other_origin: str+):+ await seed(workspace_id, MAX_SKILLS_PER_EXPERT, origin=full_origin)+ request = write(workspace_id, "other-budget")+ request.metadata = {"skill_origin": other_origin}+ result = await publish_workspace_skill_file(request)+ assert result.status == "stored"+ assert (+ await db.prisma.userworkspacefile.count(+ where={"workspaceId": workspace_id, "isDeleted": False}+ )+ == MAX_SKILLS_PER_EXPERT + 1+ )++[email protected](loop_scope="session")+async def test_origin_transfer_requires_destination_budget_slot(workspace_id: str):+ await seed(workspace_id, MAX_SKILLS_PER_EXPERT, origin="user")+ installed = write(workspace_id, "installed")+ installed.metadata = {"skill_origin": "marketplace"}+ result = await publish_workspace_skill_file(installed)+ assert result.status == "stored"+ saved = write(workspace_id, "installed")+ saved.metadata = {"skill_origin": "user"}+ rejected = await publish_workspace_skill_file(saved)+ assert rejected.status == "capacity"+ row = await db.prisma.userworkspacefile.find_unique(where={"id": installed.file_id})+ assert row is not None and not row.isDeleted+ assert row.metadata == {"skill_origin": "marketplace"}++[email protected](loop_scope="session")+async def test_concurrent_marketplace_install_cannot_replace_owner_saved_root(+ workspace_id: str,+):+ saved = write(workspace_id, "same")+ saved.metadata = {"skill_origin": "user"}+ installed = write(workspace_id, "same")+ installed.metadata = {"skill_origin": "marketplace"}+ results = await asyncio.gather(+ publish_workspace_skill_file(saved), publish_workspace_skill_file(installed)+ )+ assert results[0].status == "stored"+ assert results[1].status in {"stored", "owned"}+ row = await db.prisma.userworkspacefile.find_unique(+ where={"workspaceId_path": {"workspaceId": workspace_id, "path": saved.path}}+ )+ assert row is not None+ assert row.id == saved.file_id+ assert row.metadata == {"skill_origin": "user"}++[email protected](loop_scope="session")+async def test_marketplace_can_claim_legacy_root(workspace_id: str):+ original = await publish_workspace_skill_file(write(workspace_id, "legacy"))+ installed = write(workspace_id, "legacy")+ installed.metadata = {"skill_origin": "marketplace"}+ result = await publish_workspace_skill_file(installed)+ assert result.status == "stored"+ assert result.file is not None and original.file is not None+ assert result.file.id != original.file.id+ assert result.file.metadata == {"skill_origin": "marketplace"}++[email protected](loop_scope="session")+async def test_rename_cannot_publish_an_extra_root_at_capacity(workspace_id: str):+ await seed(workspace_id, MAX_SKILLS_PER_EXPERT)+ file = await db.prisma.userworkspacefile.create(+ data={+ "workspaceId": workspace_id,+ "name": "draft.md",+ "path": "/skills/extra/draft.md",+ "storagePath": "test://draft",+ "mimeType": "text/markdown",+ "sizeBytes": 20,+ }+ )+ with pytest.raises(SkillLimitError):+ await rename_workspace_file(file.id, workspace_id, "SKILL.md")+ row = await db.prisma.userworkspacefile.find_unique(where={"id": file.id})+ assert row is not None and row.path == "/skills/extra/draft.md"++[email protected](loop_scope="session")+async def test_rename_and_new_publication_share_last_slot(workspace_id: str):+ await seed(workspace_id, MAX_SKILLS_PER_EXPERT - 1)+ file = await db.prisma.userworkspacefile.create(+ data={+ "workspaceId": workspace_id,+ "name": "draft.md",+ "path": "/skills/renamed/draft.md",+ "storagePath": "test://draft",+ "mimeType": "text/markdown",+ "sizeBytes": 20,+ }+ )+ renamed, published = await asyncio.gather(+ rename_workspace_file(file.id, workspace_id, "SKILL.md"),+ publish_workspace_skill_file(write(workspace_id, "published")),+ return_exceptions=True,+ )+ assert not isinstance(published, BaseException)+ assert isinstance(renamed, (WorkspaceFile, SkillLimitError))+ assert (not isinstance(renamed, SkillLimitError)) + (+ published.status == "stored"+ ) == 1+ assert (+ await db.prisma.userworkspacefile.count(+ where={"workspaceId": workspace_id, "isDeleted": False, "name": "SKILL.md"}+ )+ == MAX_SKILLS_PER_EXPERT+ )diff --git a/autogpt_platform/backend/backend/util/workspace.py b/autogpt_platform/backend/backend/util/workspace.pyindex c808394c8f..3e16185930 100644--- a/autogpt_platform/backend/backend/util/workspace.py+++ b/autogpt_platform/backend/backend/util/workspace.py@@ -14,7 +14,16 @@ from typing import Optionalfrom prisma.errors import UniqueViolationErrorfrom backend.copilot.rate_limit import get_workspace_storage_limit_bytes-from backend.data.db_accessors import workspace_db+from backend.data.db_accessors import workspace_db, workspace_skill_db+from backend.data.skill_capacity import (+ MAX_SKILLS_PER_EXPERT,+ SKILL_ORIGIN_LABELS,+ SKILL_ORIGIN_USER,+ SkillLimitError,+ SkillOwnedError,+ skill_origin,+ skill_owner_folder,+)from backend.data.workspace import WorkspaceFilefrom backend.data.workspace_scope import (EXPERT_FILE_ACCESS_DENIED,@@ -22,6 +31,7 @@ from backend.data.workspace_scope import (WorkspaceAccessDeniedError,WorkspaceScope,)+from backend.data.workspace_skill import WorkspaceSkillWritefrom backend.util.settings import Configfrom backend.util.virus_scanner import scan_content_safefrom backend.util.workspace_storage import compute_file_checksum, get_workspace_storage@@ -360,8 +370,43 @@ class WorkspaceManager:) from Noneraise ValueError(f"File already exists at path: {path}")+ replaced_storage_path: str | None = None+ replaced_file_id: str | None = Nonetry:- file = await _persist_db_record()+ if skill_owner_folder(path) is not None:+ publication = await workspace_skill_db().publish_workspace_skill_file(+ WorkspaceSkillWrite(+ workspace_id=self.workspace_id,+ file_id=file_id,+ name=filename,+ path=path,+ storage_path=storage_path,+ mime_type=mime_type,+ size_bytes=len(content),+ overwrite=overwrite,+ checksum=checksum,+ metadata=metadata,+ )+ )+ if publication.status == "capacity":+ origin = skill_origin(metadata) or SKILL_ORIGIN_USER+ raise SkillLimitError(+ f"Skill limit reached ({MAX_SKILLS_PER_EXPERT} {SKILL_ORIGIN_LABELS[origin]} "+ "skills). Delete an unused skill first."+ )+ if publication.status == "owned":+ raise SkillOwnedError(+ f"'{path.rsplit('/', 2)[1]}' is one of the owner's own skills; "+ "rename or delete it before installing a skill by that name."+ )+ if publication.status == "exists":+ raise ValueError(f"File already exists at path: {path}")+ assert publication.file is not None+ file = publication.file+ replaced_storage_path = publication.replaced_storage_path+ replaced_file_id = publication.replaced_file_id+ else:+ file = await _persist_db_record()except Exception:try:await storage.delete(storage_path)@@ -369,6 +414,26 @@ class WorkspaceManager:logger.warning(f"Failed to clean up orphaned storage file: {e}")raise+ if replaced_storage_path and replaced_storage_path != storage_path:+ try:+ await storage.delete(replaced_storage_path)+ except Exception:+ logger.warning("Failed to clean up replaced skill blob", exc_info=True)++ if replaced_file_id and replaced_file_id != file.id:+ try:+ from backend.api.features.workspace.embeddings import (+ delete_workspace_file_embedding,+ )++ await delete_workspace_file_embedding(+ file_id=replaced_file_id, user_id=self.user_id+ )+ except Exception:+ logger.warning(+ "Failed to clean up replaced skill embedding", exc_info=True+ )+logger.info(f"Wrote file {file.id} ({filename}) to workspace {self.workspace_id} "f"at path {path}, size={len(content)} bytes"diff --git a/autogpt_platform/backend/backend/util/workspace_skill_test.py b/autogpt_platform/backend/backend/util/workspace_skill_test.pynew file mode 100644index 0000000000..467ce75527--- /dev/null+++ b/autogpt_platform/backend/backend/util/workspace_skill_test.py@@ -0,0 +1,97 @@+from datetime import datetime, timezone+from unittest.mock import AsyncMock, patch++import pytest++from backend.data.skill_capacity import SkillLimitError, SkillOwnedError+from backend.data.workspace import WorkspaceFile+from backend.data.workspace_skill import WorkspaceSkillPublication+from backend.util.workspace import WorkspaceManager+++def stored_file():+ return WorkspaceFile(+ id="new-root",+ workspace_id="workspace",+ name="SKILL.md",+ path="/skills/example/SKILL.md",+ storage_path="test://new",+ mime_type="text/markdown",+ size_bytes=4,+ created_at=datetime.now(timezone.utc),+ updated_at=datetime.now(timezone.utc),+ )++[email protected]("status", ["capacity", "exists", "stored", "error", "owned"])+async def test_skill_publication_cleans_only_the_appropriate_blob(status: str):+ database = AsyncMock()+ database.get_workspace_total_size.return_value = 0+ database.get_workspace_file_by_path.return_value = None+ publisher = AsyncMock()+ storage = AsyncMock()+ storage.store.return_value = "test://new"+ if status == "error":+ publisher.publish_workspace_skill_file.side_effect = RuntimeError(+ "DB unavailable"+ )+ elif status == "stored":+ publisher.publish_workspace_skill_file.return_value = WorkspaceSkillPublication(+ status="stored",+ file=stored_file(),+ replaced_storage_path="test://old",+ replaced_file_id="old-root",+ )+ else:+ publisher.publish_workspace_skill_file.return_value = WorkspaceSkillPublication(+ status=status+ )+ with (+ patch("backend.util.workspace.workspace_db", return_value=database),+ patch("backend.util.workspace.workspace_skill_db", return_value=publisher),+ patch(+ "backend.util.workspace.get_workspace_storage",+ AsyncMock(return_value=storage),+ ),+ patch(+ "backend.util.workspace.get_workspace_storage_limit_bytes",+ AsyncMock(return_value=1_000_000),+ ),+ patch("backend.util.workspace.scan_content_safe", AsyncMock()),+ patch(+ "backend.api.features.workspace.embeddings.delete_workspace_file_embedding",+ AsyncMock(),+ ) as delete_embedding,+ patch(+ "backend.api.features.workspace.embeddings.schedule_workspace_file_embedding"+ ),+ ):+ manager = WorkspaceManager("user", "workspace")+ if status == "stored":+ result = await manager.write_file(+ b"body", "SKILL.md", path="/skills/example/SKILL.md", overwrite=True+ )+ assert result.id == "new-root"+ storage.delete.assert_awaited_once_with("test://old")+ delete_embedding.assert_awaited_once_with(+ file_id="old-root", user_id="user"+ )+ else:+ error_type = (+ SkillLimitError+ if status == "capacity"+ else (+ SkillOwnedError+ if status == "owned"+ else ValueError if status == "exists" else RuntimeError+ )+ )+ with pytest.raises(error_type):+ await manager.write_file(+ b"body", "SKILL.md", path="/skills/example/SKILL.md", overwrite=True+ )+ storage.delete.assert_awaited_once_with("test://new")+ delete_embedding.assert_not_awaited()+ database.create_workspace_file.assert_not_awaited()+ database.soft_delete_workspace_file.assert_not_awaited()diff --git a/autogpt_platform/frontend/src/app/api/openapi.json b/autogpt_platform/frontend/src/app/api/openapi.jsonindex 43791b8c93..e19303e97a 100644--- a/autogpt_platform/frontend/src/app/api/openapi.json+++ b/autogpt_platform/frontend/src/app/api/openapi.json@@ -16484,7 +16484,9 @@"$ref": "#/components/responses/HTTP401NotAuthenticatedError"},"404": { "description": "File not found" },- "409": { "description": "A file with this name already exists here" },+ "409": {+ "description": "File name conflict or skill capacity reached"+ },"422": {"description": "Validation Error","content": {