KB injection tuning: pgvector substrate + retrieval telemetry + title-first auto-inject #74
Reference in New Issue
Block a user
Delete Branch "dev"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Ships the KB-injection-tuning effort (Scribe project 2, milestone 93) so stored knowledge reaches an agent's context proactively, without context bloat. Principle: push cheap awareness (titles), pull expensive content (bodies).
Step 1 — pgvector substrate (
5130197)semantic_search_notesnow ranks/filters/limits in Postgres viaVector.cosine_distance(<=>) on an HNSW cosine index, replacing the full-table Python cosine scan.0067:CREATE EXTENSION vector, JSONB→vector(384)(stale-dim rows dropped + regenerated by backfill), HNSW index. Reversible.postgres:16-alpine→pgvector/pgvector:pg17across prod, quickstart, and CI.Step 2 — retrieval telemetry (
807f478)retrieval_logstable (migration0068) +services/retrieval_telemetry.record_retrieval()(fire-and-forget), wired into the MCP search tool (source=mcp_search) and REST route (source=rest_search). Captures query, params, and per-result score distribution to tune thresholds from data.Step 3 — title-first auto-inject, Path A (
8126db3)GET /api/plugin/retrieve+build_autoinject_hint()with four anti-bloat gates: confidence threshold (stricter than pull), margin gate, per-session dedup (exclude_ids), top-k ceiling. Title-first payload (never bodies); logssource=auto_inject.UserPromptSubmitplugin hook (scribe_autoinject.sh) with per-session dedup state./api/settings. Defaults: enabled, 0.55, top-3.Step 4 — pull-path recall reflex (
eec241d)auto_injecttelemetry shows precision is the bottleneck.Verification: CI green on
devfor the code-bearing commits (incl. the real-PG17 integration lane applying migrations 0067 + 0068 and exercising the pgvector + telemetry paths).🤖 Generated with Claude Code
https://claude.ai/code/session_01Xz4j1H7pjYSjKsEpgcNH5E