provenance-aware-retrieval
Use when adding dense retrieval to RAG or graph systems.
- License 许可
- MIT
- 所属仓库
- zapabob/Skills
- 最近更新
- 2026-10-26
- Stars
- ★ 2
- Forks
- 0
01 前言 Front Matter
- name
- provenance-aware-retrieval
- author
- Hermes Agent
- license
- MIT
- version
- 1.0.0
- metadata
- { "hermes": { "tags": [ "rag", "retrieval", "embeddings", "provenance", "semantic-graph" ], "related_skills": [ "systematic-debugging", "software-development/test-driven-development" ] } }
- description
- Use when adding dense retrieval to RAG or graph systems.
03 SKILL.md 正文
Provenance-Aware Retrieval
When to Use
Use this skill when adding or evaluating dense embeddings, hybrid lexical+dense retrieval, provenance-aware graph expansion, local embedding HTTP adapters, or retrieval safety gates in a RAG or memory system.
Use this class-level skill when extending lexical RAG, memory stores, or semantic graphs with dense embeddings. Preserve the existing lexical path and treat dense retrieval as optional recall augmentation, never as a truth or trust mechanism.
Invariants
- Embedding similarity is a candidate generator only. It must never promote
accepted, merge nodes, confirmsame_as, supersede nodes, change authority or confidence, overwrite confirmed memory, or rewrite answers. - Typed graph relations, evidence, status, authority, scope, and user confirmation remain the source of truth.
- Canonical embedding text contains only
node_type,subtype,label,summary, andidentity_key. Exclude status, authority, confidence, salience, run/session identifiers, timestamps, metadata, evidence, secrets, raw transcripts, absolute paths, and rejected/superseded bodies. - Backend failure is lexical fail-open: do not fail the LLM turn or mutate SQLite. Bound warnings and use cooldowns.
Implementation sequence
- Start from current merged mainline, never an obsolete feature-branch head.
- Freeze a machine-readable lexical baseline before changing production retrieval.
- Add a backend protocol and deterministic fake backend without changing runtime behavior.
- Add sanitized canonical query/document serialization and stable SHA-256 source hashing.
- Add transactional storage and validated vector encoding before wiring dense candidates.
- Fuse lexical, identifier, and dense rankings with deterministic RRF; preserve stable tie-breakers.
- Apply status, authority, confidence, type, and run-scope filters before fusion where possible and again after fusion/expansion.
- Add bounded one-hop expansion only for provenance-relevant edge types; direct seeds outrank expansions.
- Prove disabled and failed-backend results preserve lexical rows and the bounded
data_onlycontext. - Add the production backend, operator controls, rebuild tooling, and live A/B evaluation last.
Evaluation
Track category-level Recall@8 and MRR@8, latency p50/p95, context size, rejected/superseded leakage, cross-run leakage, secret-bearing recall, state mutation, negative wrong-memory hit rate, and negative context-injection rate. Never accept aggregate improvement while identifier, correction/history, or safety categories regress. Leakage and mutation counters must remain zero. Record baseline limitations honestly instead of redefining metrics.
Local embedding backend
For fully local deployment, use a dedicated operator-managed LlamaCppEmbeddingBackend backed by llama-server --embedding, not a generic remote service. Use POST /v1/embeddings only, bind loopback by default, and let Hermes connect without auto-starting the server. For Qwen3-Embedding-0.6B, establish F16 at native 1024 dimensions first; evaluate Q8_0 or 512-dimensional truncation only through later benchmarks. Query serialization receives the model instruction; documents do not.
Validate HTTP status, JSON shape, response count, complete unique indices, dimensions, finite values, nonzero norm, response size, timeout, and cooldown. Reorder by response index. Do not infer identity from response model; use configured model, GGUF revision, dimensions, and serializer version.
Sanitization and stale vectors
Reuse the shared sanitizer, but enforce field bounds after sanitization and normalization. Persistence redaction may turn benign long tokens into [LONG_TOKEN_REDACTED]; use a slightly larger sanitizer budget and truncate after normalization. Invalidate stale vectors both on semantic-field updates and by source-hash mismatch at query time. Never use Python's salted hash() for stable identity.
Verification
Keep protocol, serializer, migration, vector math, RRF, filters, expansion, fallback, HTTP adapter, and CLI in logical commits. Use RED → GREEN → regression verification. On Windows Git Bash, use:
SHORT=$(cygpath -d "$PWD/.venv/Scripts/python.exe")
HERMES_PYTHON="$SHORT" HERMES_TEST_WORKERS=1 bash scripts/run_tests.sh <tests> -q
Before each commit run canonical tests, static checks, git diff --check, and secret/path scans. After committing, rerun the targeted set and prove intended production-boundary files are unchanged. Record commands, exit codes, skipped live checks, risks, and working-tree status in the implementation log. Do not claim production readiness without full-suite, restart, provider, and live-backend evidence.
References
references/hybrid-retrieval-llama-cpp.md: benchmark, RRF, filtering, serializer, adapter, and Windows verification details.references/llama-server-embedding.md: llama-server/Qwen3 request, response validation, identity, and security cheatsheet.
04 同仓库更多 Skills
xurl
X/Twitter via xurl CLI: post, search, DM, media, v2 API.
writing-plans
Write implementation plans: bite-sized tasks, paths, code.
whisper
OpenAI's general-purpose speech recognition model. Supports 99 languages, transcription, translation to English, and language identification. Six model sizes from tiny (39M params) to large (1550M params). Use for speech-to-text, podcast transcription, or multilingual audio processing. Best for robust, multilingual ASR.
weights-and-biases
W&B: log ML experiments, sweeps, model registry, dashboards.
watchers
Poll RSS, JSON APIs, and GitHub with watermark dedup.
serving-llms-vllm
vLLM: high-throughput LLM serving, OpenAI API, quantization.