[F011] playbook: de-index rejected/archived playbooks from the PLAYBOOKS RAG index

This commit is contained in:
Renn F
2026-06-28 10:38:28 +02:00
parent fc3ec109e7
commit 7cba2f9793
6 changed files with 248 additions and 1 deletions
@@ -38,3 +38,24 @@ def test_build_source_uri_with_id() -> None:
def test_build_source_uri_none_when_missing() -> None:
assert _plugin().build_source_uri(doc_id=None) is None
def test_delete_playbook_removes_its_chunks_by_source() -> None:
"""F011: deleting a playbook removes its embedded chunks from the vector
store by the playbook's source URI (idempotent — no-op if absent). A
rejected/archived playbook must not stay retrievable in the PLAYBOOKS index."""
from unittest.mock import AsyncMock, MagicMock
plugin = PlaybooksIndexPlugin.__new__(PlaybooksIndexPlugin)
store = MagicMock()
store.delete_by_source = AsyncMock(return_value=None)
# Bypass the initialized-guard property so the unit test doesn't need a
# live pgvector store.
object.__setattr__(plugin, "_initialized", True)
object.__setattr__(plugin, "_store", store)
import asyncio
asyncio.run(plugin.delete_playbook("pb-42"))
store.delete_by_source.assert_awaited_once_with("roboco://playbooks/pb-42")