Skip to content

fix(ai): the knowledge base is re-indexed whenever the installed knowledge base differs from what its collection holds, and rag status and drift read Qdrant instead of the local cache #1139

Closed

Description

@dan-petty

Problem

  • Nothing runs KB ingestion. devops ai rag index-kb exists [code: commands/rag.py:218], but no command, schedule or hook runs it (R2).
  • The collections have been empty since 2026-09-30. A search wiped them that day, nothing has been upserted since, and 2,084/2,084 searches in the loop returned nothing [measured: loop §3; u-reference].
  • Drift cannot see the wipe. rag drift --auto-sync compares workspace files against the local index cache, not Qdrant [code: ai/rag/drift.py:205-213], so a wiped collection under an intact cache reads as no drift.
  • rag status shows vector size 0 [code: commands/rag.py:453-455].
  • No collection records which KB it holds, so an upgraded KB is never re-indexed.

Acceptance criteria

  • The collection records what it holds. KB points carry the installed KB's digest (sha256 over sorted relative paths and contents), alongside fix(ai): a rag collection records its embedding model, a mismatch fails instead of wiping the collection, and ranking keeps the cosine score #1066's embedding_model.
  • The KB is rebuilt on use.
    • On the first RAG use in a process (chat lookup, rag query, the MCP RAG tools), the KB is re-indexed before the lookup, with one progress line, when either:
      • the collection holds no KB points; or
      • its recorded digest differs from the installed one.
    • After a failure it is tried again at most once per 30 minutes, and the failure is printed once.
  • Drift reads Qdrant. rag drift compares per-project Qdrant point counts and the KB digest, not only the cache. A fake-client test of a wiped collection under an intact cache reports drift.
  • Status says what is indexed. rag status shows, per collection: points, embedding model, dimension, KB digest and last index time.
  • A devops_cli_rag_points gauge is emitted on use (fix(telemetry): the project velocity dashboard reads the latest snapshot of each gauge, and the project gauges drop the _total suffix #974).
  • (person-run) After an upgrade:
    • rag status shows KB points at the installed digest;
    • a devops ai chat question about PEP 758 cites the KB topic manual.
  • Tests run offline with fakes and recorded tool output: no network, no real scanner, no model; each test under 1 s.
  • changelog.d/<n>.md records the change; CHANGELOG.md and docs/ROADMAP.md are not edited.
  • uv run devops ci passes.

Key questions

Strategic alignment

Update 2026-10-08: refinement

rag index already indexes the KB as devops-cli-kb (commands/rag.py:115-121); the missing part is the trigger and comparison. The collections are no longer empty (#1388), but drift reads only the local cache (ai/rag/drift.py:213). Whichever of #1388 and this item lands second reuses the other's count read.

Activity

  1. added
    type/bug
    scope/ai
    priority/p1-high
    on Oct 3, 2026
  2. added this to the v0.2.34 milestone on Oct 10, 2026
  3. dan-petty-bot commented on Oct 10, 2026

    @dan-petty-bot
    Collaborator

    Moved to v0.2.34: v0.2.34 started with fewer than its 16 items and was topped up to 16 from Ready items, critical fixes and P0 features first. (devops roadmap reprioritize)

  4. dan-petty commented on Oct 11, 2026

    @dan-petty
    OwnerAuthor

    Merged

  5. added a commit that references this issue on Oct 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    priority/p1-highscope/aitype/bug

    Type

    No type

    Projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions