mirror of
https://github.com/rennf93/roboco.git
synced 2026-08-03 07:23:24 +02:00
* feat(vault): V2 — create-seam + drift janitor, archival, weekly org-report, KB ingest, Bases views + sync runbook Implements the vault V2 canonical spec end to end (the splice guard shipped separately and is reused at KB-ingest time): - materialize-on-create: TaskService.create writes each task's note best-effort from the moment it exists; the transition-touch stops no-oping on live work - drift janitor (services/vault_janitor.py + hourly _vault_janitor_loop): daily changed-task re-projection, random drift sample, archival pass — restart-proof via RoboCo/_meta/.janitor_state.json, 200/cycle caps, per-item isolation, processed-only resume markers, self-repairing state file - archival: vault_archive_days (30, 0=off) moves old terminal tasks' notes to RoboCo/Archive/<year>/Tasks/<project>/ — one write_task code path for janitor and rebuild, id8 lookup across Tasks/+Archive/, alias links keep moves safe - weekly org-report: VaultWriter.write_org_report renders Reports/<ISO-week>.md from MetricsService/UsageService (numbers duplicated into frontmatter for trend queries), once per ISO week, with a best-effort CEO notification - KB ingest: IndexType.VAULT_NOTES + VaultNotesIndexPlugin + _vault_kb_loop embed the CEO's RoboCo/Notes into the RAG corpus — injection guard as a hard gate (flagged notes quarantined with an idempotent callout), traversal- and symlink-contained at both config and engine layers, content-hash dedup, 50-ingest/cycle cap, frontmatter stripped; reaches roboco_kb_search, the mentor default domain, claim-time briefings (kind vault_note), and the panel KB browser; no migration (chunks table auto-creates; migration 030's CHUNK_TABLES tuple appended per the chunks_playbooks precedent) - Bases views (Task Board.base, Reports.base — schema verified against the Obsidian docs) + the Mac sync runbook vault asset - config/flags/compose: vault_archive_days, vault_report_enabled (flags card), vault_kb_enabled (flags card; NAS compose arms it, registry ships it off), vault_kb_dirs (+ overlap/traversal validator), vault_kb_interval_seconds - e2e smoke (tests/e2e_smoke/test_vault_v2.py): real create-seam, real janitor cycle incl. archival + state, real KB engine + real guard * docs: vault V2 sweep — map, RAG corpus, CLAUDE.md - docs/map/vault.md: V1+V2 — janitor/archival/report/KB data flows, new files, config, health posture - docs/map/orchestrator.md + task-service.md: the two new loops, the create seam, the three janitor queries - docs/rag/architecture/obsidian-vault.md: agent-facing what-changed (notes from creation, archive link-safety, CEO notes retrievable, weekly report) - docs/rag/architecture/config-reference.md: the five new settings - CLAUDE.md: vault paragraph covers V1+V2; flags-card list mentions the vault report/KB flags --------- Co-authored-by: Renn F <rennf93@users.noreply.github.com>
73 lines
2.7 KiB
Python
73 lines
2.7 KiB
Python
"""VaultNotesIndexPlugin — 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 index plugins) and runs live.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
import asyncio
|
|
from unittest.mock import AsyncMock, MagicMock
|
|
|
|
from roboco.models.optimal import IndexType
|
|
from roboco.services.optimal_brain.indexes.base import IndexConfig
|
|
from roboco.services.optimal_brain.indexes.vault_notes import VaultNotesIndexPlugin
|
|
|
|
|
|
def _plugin() -> VaultNotesIndexPlugin:
|
|
return VaultNotesIndexPlugin.__new__(VaultNotesIndexPlugin)
|
|
|
|
|
|
def test_index_type_is_vault_notes() -> None:
|
|
assert _plugin().index_type == IndexType.VAULT_NOTES
|
|
|
|
|
|
def test_prepare_metadata_carries_path_and_hash() -> None:
|
|
md = _plugin().prepare_metadata(
|
|
"content", path="RoboCo/Notes/a.md", title="A", content_hash="abc123"
|
|
)
|
|
assert md["type"] == "vault_note"
|
|
assert md["source"] == "vault"
|
|
assert md["path"] == "RoboCo/Notes/a.md"
|
|
assert md["title"] == "A"
|
|
assert md["content_hash"] == "abc123"
|
|
|
|
|
|
def test_build_source_uri_with_path() -> None:
|
|
assert (
|
|
_plugin().build_source_uri(doc_id="RoboCo/Notes/a.md")
|
|
== "vault://RoboCo/Notes/a.md"
|
|
)
|
|
|
|
|
|
def test_build_source_uri_none_when_missing() -> None:
|
|
assert _plugin().build_source_uri(doc_id=None) is None
|
|
|
|
|
|
_SHORT_NOTE_FLOOR = 40 # journals-style floor; the global default is 200
|
|
|
|
|
|
def test_min_chunk_length_floor_allows_short_notes() -> None:
|
|
"""CEO vault notes are often a few short lines — the global 200-char
|
|
quality floor would discard them all as garbage (the exact failure the
|
|
journals/learnings floors fixed). Same floor as journals."""
|
|
vault_floor = IndexConfig.from_settings(IndexType.VAULT_NOTES).min_chunk_length
|
|
journal_floor = IndexConfig.from_settings(IndexType.JOURNALS).min_chunk_length
|
|
assert vault_floor == journal_floor == _SHORT_NOTE_FLOOR
|
|
|
|
|
|
def test_delete_note_removes_its_chunks_by_source() -> None:
|
|
"""Deleting a note removes its embedded chunks from the vector store by
|
|
the note's source URI (idempotent — no-op if absent). A deleted/moved
|
|
note must not stay retrievable in the VAULT_NOTES index."""
|
|
plugin = VaultNotesIndexPlugin.__new__(VaultNotesIndexPlugin)
|
|
store = MagicMock()
|
|
store.delete_by_source = AsyncMock(return_value=None)
|
|
object.__setattr__(plugin, "_initialized", True)
|
|
object.__setattr__(plugin, "_store", store)
|
|
|
|
asyncio.run(plugin.delete_note("RoboCo/Notes/a.md"))
|
|
|
|
store.delete_by_source.assert_awaited_once_with("vault://RoboCo/Notes/a.md")
|