Files
roboco/tests/unit/services/optimal_brain/test_playbooks_index.py
T
5612375cba Feat/v0.13.0 (#270)
* feat(release): add release-manager feature flag (default off)

* feat(release): change classification + semver-bump derivation

* feat(release): readiness audit (changelog/version-ref/docs/migration/gate)

* feat(release): release-manager engine proposes a gated release

* feat(release): fail-closed release executor (bump, gate, publish)

* feat(release): CEO approve/reject release-proposal surface

* docs(release): document the gated release manager

* feat(memory): add org-memory feature flags (default off)

* feat(memory): add playbooks table + status enum + migration

* feat(memory): playbook service with auditor curation transitions

* feat(memory): playbooks RAG index plugin

* feat(memory): index a playbook into RAG on approval

* feat(memory): distill a high-signal lesson at task completion

* feat(memory): keep private journal reflections out of the shared RAG corpus

* feat(memory): draft_playbook verb + auditor curation verbs

* fix(ci): resolve mypy tests/ errors blocking the gate (UUID casts, annotations)

* feat(memory): auto-inject similar lessons/playbooks into the briefing

* feat(memory): auditor playbook review queue (api + panel)

* docs(memory): document the org-memory loop + playbook verbs

* fix(provisioning): idempotent pitch provisioning (reuse product/project by slug on re-approval)

* fix(memory): add chunks_playbooks to the chunk schema + isolate release route tests

- Migration 030's CHUNK_TABLES was missing chunks_playbooks, breaking the
  IndexType<->migration parity guard once the PLAYBOOKS index landed. The
  upgrade is ALTER ... IF EXISTS so adding it is safe on any DB shape.
- The release-route fixture's approve/reject paths call db.commit() (real
  behavior), so a held proposal outlived the per-test rollback and leaked
  into engine tests that read the global list_open_release_proposals().
  Tear down source=release_manager rows after each test.
- Make the gather_snapshot real-repo smoke version-agnostic (semver match)
  so it stops pinning the literal repo version.

* chore(release): 0.13.0

* ++

---------

Co-authored-by: Renn F <rennf93@users.noreply.github.com>
2026-06-26 01:43:08 +02:00

41 lines
1.4 KiB
Python

"""PlaybooksIndexPlugin — index_type + pure metadata/URI methods.
Mirrors the other index-plugin unit tests (instantiate via __new__, exercise the
pure methods). The embed + pgvector ingest/search path is inherited from
BaseIndexPlugin (shared, proven by the other 8 plugins) and runs live.
"""
from __future__ import annotations
from roboco.models.optimal import IndexType
from roboco.services.optimal_brain.indexes.playbooks import PlaybooksIndexPlugin
def _plugin() -> PlaybooksIndexPlugin:
return PlaybooksIndexPlugin.__new__(PlaybooksIndexPlugin)
def test_index_type_is_playbooks() -> None:
assert _plugin().index_type == IndexType.PLAYBOOKS
def test_prepare_metadata_marks_approved_with_routing_fields() -> None:
md = _plugin().prepare_metadata(
"content", playbook_id="pb-1", team="backend", scope="org", tags=["retry"]
)
assert md["type"] == "playbook"
assert md["playbook_id"] == "pb-1"
assert md["team"] == "backend"
assert md["scope"] == "org"
assert md["tags"] == ["retry"]
# Only approved playbooks are ever indexed — the metadata says so.
assert md["status"] == "approved"
def test_build_source_uri_with_id() -> None:
assert _plugin().build_source_uri(doc_id="pb-1") == "roboco://playbooks/pb-1"
def test_build_source_uri_none_when_missing() -> None:
assert _plugin().build_source_uri(doc_id=None) is None