Skip to content

Self-evolving Context Database for AI Agents. Unify Agent Memory, Knowledge RAG and Skills.

fix(storage): block deleting the write-protected viking://agent root (parity with #2873) (#2914)

Evo631d7ca98f0f
diff --git a/openviking/storage/viking_fs.py b/openviking/storage/viking_fs.py
index 7bb9eb174..d4782c77e 100644
--- a/openviking/storage/viking_fs.py
+++ b/openviking/storage/viking_fs.py
@@ -434,6 +434,16 @@ class VikingFS:
"or current-user content path instead.",
resource=normalized_uri,
)
+ if parts == ["agent"]:
+ # Parity with _ensure_supported_write_namespace, which forbids the
+ # account-shared viking://agent root: deleting it would recursively
+ # wipe every account's agent skills/endpoints/tools/payments. Concrete
+ # sub-paths (viking://agent/skills/...) remain deletable.
+ raise PermissionDeniedError(
+ "Deleting viking://agent root is not supported; use a concrete "
+ "agent sub-path (e.g. viking://agent/skills/...) instead.",
+ resource=normalized_uri,
+ )
def _ensure_supported_write_namespace(self, normalized_uri: str) -> None:
parts = [p for p in normalized_uri[len("viking://") :].strip("/").split("/") if p]
diff --git a/tests/misc/test_vikingfs_uri_guard.py b/tests/misc/test_vikingfs_uri_guard.py
index 8fab4255e..aa6eb0f31 100644
--- a/tests/misc/test_vikingfs_uri_guard.py
+++ b/tests/misc/test_vikingfs_uri_guard.py
@@ -113,6 +113,8 @@ class TestVikingFSURITraversalGuard:
"viking://user/",
"/user",
"user",
+ "viking://agent",
+ "viking://agent/",
],
)
async def test_rm_rejects_protected_namespace_roots_before_side_effects(