Repository navigation
Description
Refreshed plan (2026-10-17, unblocking review)
This section supersedes any text below that conflicts with it.
Decisions
- Decision D11 (owner, 2026-10-17): "feat(rag): Index managed repos, exclude private from unscoped search #1389 is split into a CLI ingestion pass now and an Argo cluster lane later (new item)." This item blocks the CLI pass directly, and blocks the cluster lane through feat(rag): Index managed repos, exclude private from unscoped search #1389.
- Decision D16 (owner, 2026-10-17): "v0.2.38 may go over the cap of 16 for now; unblocking work goes first." This item merges before feat(rag): Index managed repos, exclude private from unscoped search #1389.
- The intact check and the recorded counts use
QdrantClient.count_points, which is exact and raisesQdrantClientError. They do not use drift's_count_collection_project_points, because that helper reads a failed count as 0 and would start a full re-embed on every transient error. _safe_delete_points_by_filesand itshasattrfallbacks are deleted, and so isdelete_points_by_file, whose only caller insrc/is that fallback. The tests that call or fake it (tests/test_rag_qdrant.py:143,tests/test_rag_indexer_retriever.py:73,tests/test_rag_multi_project_indexer.py:66) change with it. The purges calldelete_points_by_files(..., wait=True)directly, because the fallback sends unwaited deletes and itsFalseis the swallowed failure this item removes.- The payload-index list is a constant in
src/devops_cli/config/constants.pybesideCONST_RAG_KB_PROJECT, because AGENTS.md puts such lists there. feat(rag): Index managed repos, exclude private from unscoped search #1389's CLI pass appendsvisibilityto it. - The knowledge base's project name comes from
CONST_RAG_KB_PROJECTin_resolve_indexing_target_metadataandindex_knowledge_base, replacing the two"devops-cli-kb"literals, because the project name now feeds every point id. - Priority: P2, as the body proposes. The issue has no priority label yet. Its one dependent, feat(rag): Index managed repos, exclude private from unscoped search #1389, has no priority label, so the owner's blocker rule raises nothing.
Scope
- Unchanged. Reproduced again offline at 3dd7fa6 on 2026-10-17: lines 26-34 of this repository's
README.mdand of the knowledge base'sREADME.mdstill get the same id,8579c001-4bfc-f2dc-f156-7773b3c00690. - fix(ai): a rag collection records its embedding model, a mismatch fails instead of wiping the collection, and ranking keeps the cosine score #1066 and 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 landed in v0.2.34, so this item is the one that lands second in both of the body's notes. It rebases on 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 compatibility check and
embedding_modelpayload field, and it reuses 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'skb_digestpayload field andcount_points.
Delivery
- One PR, size M, into
main, withCloses #1388. feat(rag): Index managed repos, exclude private from unscoped search #1389's CLI pass starts after it merges.
Acceptance criteria (these add to the criteria below; every criterion below still stands)
- A count that raises fails the run and re-indexes nothing. A collection that does not exist counts as 0, so a deleted collection triggers the re-index under the criteria below.
- No delete path sends
wait=False. A test asserts that every delete the fake records waited. - A test: an existing collection without the payload indexes gets both on the next index run. Today the branch where the dimension matches returns before any index work, and indexing reaches
ensure_collectiononly throughupsert_points, so a run that embeds nothing never calls it.
Current references (checked at 3dd7fa6; each line gives the current location, then the body's old citation)
- Collection names:
src/devops_cli/commands/rag.py:84-86(was :78-79).--include-kb, on by default:rag.py:122-128(was :115-121). - Id:
src/devops_cli/ai/rag/chunker.py:779-783, called at:308,:651,:683and:714(unchanged)._coerce_point_id:src/devops_cli/ai/rag/qdrant.py:92-102(was :63-73). - Knowledge-base project and relative base:
src/devops_cli/ai/rag/indexer.py:344-346, relative path at:351-352(was :322-324). The second literal is atindexer.py:684.CONST_RAG_KB_PROJECTis atsrc/devops_cli/config/constants.py:2040. - Skip when the cache hash matches:
indexer.py:383(was :361). _safe_delete_points_by_files:indexer.py:203-223, withwait=Falseat:216(was :204)._purge_deleted_vectors: scanned projects atindexer.py:236-240(was :224-227). The cache entry is dropped at:253, before the deletes at:257-258(was :241 and :245-246)._purge_obsolete_pointsignores the result:indexer.py:297-298(was :285-286).force: empty cache atindexer.py:713(was :568), deleted-file purge skipped at:737(was :592), final save at:799(was :654)._update_incremental_cache:indexer.py:153-175, called per batch at:892(was :148-170)._load_cache::623-629(was :481-487)._save_cache, withPath.write_textand a DEBUG log::631-636(was :489-492).delete_points_by_files:qdrant.py:578-633. It filters onfile_pathandproject_nameat:598-608, and logs at DEBUG and returnsFalseat:625-633(was :493-548, :509-523 and :540-548).delete_points_by_file, withwait=False::635-639.ensure_collection:qdrant.py:348-398, with no payload index. It returns early at:361-362and:379-381(was :313-359). Indexing reaches it only fromupsert_points(qdrant.py:441). The library store also calls it (src/devops_cli/ai/rag/library_store.py:228).count_points:qdrant.py:522-537, exact. It returns 0 for a collection that is not found (:534-535) and raises otherwise (:537). Drift's per-project count, which returns 0 on an error:src/devops_cli/ai/rag/drift.py:197-214.- 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 compatibility check:
indexer.py:547, run before indexing at:700-701. The point payload is built atindexer.py:304-330. rag clear: deletes the collections atrag.py:609-610and removes only the local cache at:619-621(was :542 and :553).- Retriever filter:
src/devops_cli/ai/rag/retriever.py:67-83, withproject_nameat:77-78(was :63-79). Collections searched::378-386(was :277-285). - Unchanged:
write_json_fileatsrc/devops_cli/output/file_writer.py:202, andtest_multi_project_indexingattests/test_rag_multi_project_indexer.py:25.
Dependencies and order
- Depends on nothing open. fix(ai): a rag collection records its embedding model, a mismatch fails instead of wiping the collection, and ranking keeps the cosine score #1066 (closed 2026-10-11, v0.2.34), 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 2026-10-11, v0.2.34) and fix(ai): an interrupted rag index resumes every file whose chunks were not all stored #1296 (closed 2026-10-08, v0.2.28) have landed.
- Blocks feat(rag): Index managed repos, exclude private from unscoped search #1389 (open, no milestone, no priority,
status/blocked). After D11, feat(rag): Index managed repos, exclude private from unscoped search #1389's CLI pass depends on this item only, and it usespoints_intactand the index constant. The new cluster-lane item depends on feat(rag): Index managed repos, exclude private from unscoped search #1389. - Related, open and in the backlog: refactor(ai): Valkey, Qdrant and the embedder each have one seam, with shared fakes and contract suites #1317 and test(ai): Wire rag once in ai/rag, test with edge fakes #1329 (P2), which can adopt this item's fake because it stays at the client edge; fix(ai): rag chunks stay under the embedder's real token limit, not a four-characters-per-token estimate #1300 (P2), chunk sizes.
Problem
WorkspaceIndexer writes every project into the same two collections (<qdrant.collection_prefix>_code and _docs, src/devops_cli/commands/rag.py:78-79). It tells projects apart only by the project_name payload field, and several paths still assume one project per collection.
State on 2026-10-08.
devops ai rag statusshowed 7,168 points indevops_codeand 4,691 indevops_docs.- The local index cache was last written on 2026-10-06. It lists 1,801 files in two projects: 1,720 of this repository and 81 of the bundled knowledge base (
devops-cli-kb). - So the collections were refilled after the 2026-09-30 wipe that 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 records.
Two projects that share a file path overwrite each other's points, and a default index already does this.
- A point's id hashes only
file_path:start_line:end_line(src/devops_cli/ai/rag/chunker.py:779-783, called at:308,:651,:683and:714). The project is not part of it._coerce_point_idkeeps a UUID-shaped id as it is (src/devops_cli/ai/rag/qdrant.py:63-73), and a Qdrant upsert replaces the point with the same id. devops ai rag indexincludes the knowledge base by default (--include-kb,rag.py:115-121). Its files are indexed as projectdevops-cli-kb, with paths relative to the knowledge-base directory (src/devops_cli/ai/rag/indexer.py:322-324). Both trees have a rootREADME.md.- Reproduced offline at 910b823 on 2026-10-08: lines 26-34 of this repository's
README.mdand of the knowledge base'sREADME.mdget the same id,8579c001-4bfc-f2dc-f156-7773b3c00690. On every default index, whichever is written second replaces the other in the docs collection, and the payload then names the second project. - What follows:
- the first project's cache still lists the file at its hash (
indexer.py:361), so it never embeds the file again; - when the second project later changes or deletes the file, the delete filtered on its
project_name(qdrant.py:493-548) removes the only copy.
- the first project's cache still lists the file at its hash (
- feat(rag): Index managed repos, exclude private from unscoped search #1389 would put eight repositories into these collections.
README.md,LICENSEandpyproject.tomlexist in most of them, often with identical first sections. test_multi_project_indexing(tests/test_rag_multi_project_indexer.py:25) indexes two projects whose paths differ, so it doesn't catch this.
A delete that fails is forgotten.
_purge_deleted_vectorsremoves a file's cache entry (indexer.py:241) before it asks for the delete (:245-246), and ignores the result.- The delete is sent with
wait=False(indexer.py:204).delete_points_by_fileslogs a failure at DEBUG and returnsFalse(qdrant.py:540-548). - So a Qdrant timeout during a purge leaves the deleted file's chunks in the collection for good, and no cache entry is left to retry from.
_purge_obsolete_pointsignores the result the same way (indexer.py:285-286). If a changed file got shorter, the chunks for its old line ranges stay.
A purge needs a scanned file. Deleted files are looked for only in projects that appear in this run's file_hashes (indexer.py:224-227). If every indexable file of a project is deleted, nothing is purged.
--force drops other projects' cache entries and orphans the points of deleted files.
- With
force,index_workspacestarts from an empty dict (indexer.py:568) and saves that dict over the single cache file (:489-492,:654). The next run of any other project then embeds all of it again. For this repository that is about 20,000 chunks at 910b823: 20,359 from 1,830 files, counted offline. fix(ai): a rag collection records its embedding model, a mismatch fails instead of wiping the collection, and ranking keeps the cosine score #1066 estimated 17,500 chunks and 15-30 minutes on the background tier. forcealso skips_purge_deleted_vectors(indexer.py:592). A file deleted since the last run has no cache entry afterwards, so its points are never deleted.
The cache file is rewritten in place. _save_cache writes with Path.write_text (indexer.py:489-492) after every batch (_update_incremental_cache, :148-170), and logs a failure at DEBUG. A process killed mid-write leaves a truncated file. _load_cache then returns {} (:481-487), and the next run embeds every project again.
A collection that lost a project's points is never refilled.
- A file is skipped when its cache hash matches (
indexer.py:361), whatever the collection holds. - Collections get emptied in more than one way:
- on 2026-09-30 a search deleted and recreated both collections (feat(review): evidence-first code review — tools find, version-pinned facts ground, models explain and plan, fixes are re-checked #1137, R1);
devops ai rag cleardeletes the collections, but removes only the workstation's own cache file (rag.py:542,:553);rag clear --collection <name>empties just one of the two.
- Any other cache, on another workstation or in the Service (feat(rag): Index managed repos, exclude private from unscoped search #1389), then skips every file.
- 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 makes
rag driftandrag statussee this. The indexer itself still skips.
No payload index.
ensure_collectioncreates a collection without any payload index (qdrant.py:313-359).- Deletes filter on
file_pathandproject_name(qdrant.py:509-523), and searches filter onproject_name(src/devops_cli/ai/rag/retriever.py:63-79). - Qdrant's indexing documentation says "Queries that filter on unindexed fields are not only slower; they can also unnecessarily consume cluster resources", and "Payload indexes should be created before ingesting data".
- Its multitenancy guide recommends one collection with a keyword index on the tenant field, created with
is_tenant=true. The cluster runs Qdrant v1.19.1, andis_tenantneeds 1.11 or later.
Acceptance criteria
- A point's id is
uuid.uuid5over the project name, the relative path and the line range, so two projects never share an id. The hand-formatted digest in_generate_idgoes. - Deletes are sent with
wait=True.delete_points_by_filesraisesQdrantClientErroron failure instead of returningFalse. -
_purge_deleted_vectorsdrops a cache entry only after that file's points are deleted from both collections._purge_obsolete_pointsfails the run the same way. A failed run keeps the entries, so the next run retries the delete. - When
projectis given, deleted files are looked for among that project's cache entries, even if the scan found no file. -
--forcefor a project:- first deletes all of that project's points from both collections, with a waited delete filtered on
project_name; - then drops only that project's cache entries and embeds it in full.
- Every other project's entries stay.
- first deletes all of that project's points from both collections, with a waited delete filtered on
- The cache file is written atomically through
write_json_file(..., atomic=True)(src/devops_cli/output/file_writer.py:202). A failed write raises instead of being logged at DEBUG. - After a successful run, the indexer records each scanned project's point count per collection (Qdrant
count, exact, filtered onproject_name). The record goes in a small file beside the cache, written the same way. It does not go in the cache itself, a flatproject:pathmap that the purge splits on:. - Before it scans a project, the indexer counts that project's points again. It re-indexes the project as
--forcedoes, and logs one INFO line naming the project and the collection, when either:- a collection that held points for the project at the last recorded run now holds none; or
- there is no record yet, the cache lists files for the project, and both collections hold none.
-
WorkspaceIndexeralso exposes that check on its own, for examplepoints_intact(project) -> bool, so a caller can run it without scanning a tree. feat(rag): Index managed repos, exclude private from unscoped search #1389 uses it. - When
ensure_collectioncreates a collection, it also creates keyword payload indexes onproject_name(is_tenant: true) andfile_path. On an existing collection it adds whichever index is missing. The list of indexes is one constant that other items can extend. - Tests use a fake Qdrant client that keeps points by id and records requests, and a fake embedder. They make no network call, and each runs in under 1 s. All but the last fail on today's code:
- a tree and the knowledge base, each with a
README.md, keep both points for lines 26-34 after one default index; - two projects with the same
README.mdeach keep their own point, and deleting the file from one project leaves the other's point; - a delete that raises leaves the cache entry, and the next run deletes the points;
- deleting every file of a project purges all of its points;
--forceon project A keeps project B's cache entries;- a file deleted between two runs, where the second run uses
--force, leaves no point for the deleted path; - with counts recorded, emptying one of the two collections makes the next run embed every file of the project;
- with no record, a cache that lists a project's files over two collections that hold no point for it makes the next run embed every file;
- a cache write that raises halfway leaves the previous file readable;
- a new collection gets both payload indexes.
- a tree and the knowledge base, each with a
- It says that point ids changed, and that one
devops ai rag index <checkout> --forcemoves an existing index to the new ids. -
uv run devops cipasses. - Pending a person, after merge:
- Run
devops ai rag index <checkout> --forceonce. It deletes the checkout's and the knowledge base's points and embeds both under the new ids. That also restores theREADME.mdchunk the collision replaced. devops ai rag query "<a phrase from README.md lines 26-34>" --project devops-cli-kbreturns the knowledge base's chunk. The same query with--project <checkout's project>returns the checkout's chunk.devops ai rag index <checkout A> --project <a> --no-include-kb, thendevops ai rag index <checkout B> --project <b> --no-include-kb, for two checkouts that both have aREADME.md.devops ai rag query "<a phrase from A's README>" --project <a>returns A's chunk, and the same check for B returns B's.devops ai rag statusshows both collections non-empty.
- Run
Key questions
- One collection per repository instead of ids that include the project? Proposed: no.
- Qdrant's multitenancy guide says "Creating a separate collection for each tenant is rarely the most efficient approach", and "Only create multiple collections when you have a limited number of tenants that need strict isolation."
- The retriever searches two collections (
retriever.py:277-285). Per-repository collections would make every search fan out over two collections per repository. - A payload filter plus an
is_tenantindex is what the guide recommends. feat(rag): Index managed repos, exclude private from unscoped search #1389 explains why private repositories also stay in the shared collections.
- What happens to points written with the old ids? Proposed: no migration, and no
rag clearrequired (pre-1.0).- Every delete filters on
project_nameandfile_path, never on the id (qdrant.py:493-548). - So an old-id point is removed when its file changes or is deleted, and it never piles up beside a new-id copy.
- One
rag index --forceper checkout moves an index to the new ids at once. The pull request body and the person-run step say so.
- Every delete filters on
- Isn't counting on every run expensive? Proposed: no. It is two exact
countrequests per project before a run and two after it, on a field this item indexes. One embedding batch costs far more. - Should this item make
rag driftandrag statusread Qdrant? Proposed: no, 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 does that. Both read per-project counts, and whichever lands second reuses the other's read. - Does
wait=Trueslow indexing? Proposed: accept the cost. A purge is one request per 100 files per collection. Waiting for it is what makes "deleted" true before the cache forgets the file.
Strategic alignment
- Priority: P2.
- The collision happens today, but on one chunk per default index (
README.mdlines 26-34). The other defects need a failed delete, a--forcerun or a lost collection. - Once eight repositories share the collections, every shared path collides. feat(rag): Index managed repos, exclude private from unscoped search #1389 depends on this item.
- The collision happens today, but on one chunk per default index (
- Value: M. Effort: M. The item touches ids, delete semantics, both purges,
--force, the cache write, a count check and payload indexes, and it brings about ten tests with a shared fake. - Library-first: no new dependency and no hand-rolled helper.
- Ids come from the standard library's
uuid.uuid5, which replaces the hand-formatted digest. count,create_payload_index(KeywordIndexParamswithis_tenant), waited deletes and delete by filter areqdrant-client's own.- The atomic write is the existing
write_json_file.
- Ids come from the standard library's
- Depends on: nothing.
- Blocks: feat(rag): Index managed repos, exclude private from unscoped search #1389.
- Related:
- 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: the KB is re-indexed on use, and drift and status read Qdrant.
- fix(ai): a rag collection records its embedding model, a mismatch fails instead of wiping the collection, and ranking keeps the cosine score #1066 records the embedding model in each point's payload, and also edits
qdrant.pyand the point payload. Whichever lands second rebases. - fix(ai): an interrupted rag index resumes every file whose chunks were not all stored #1296: incomplete-file markers, kept as they are.
- refactor(ai): Valkey, Qdrant and the embedder each have one seam, with shared fakes and contract suites #1317 and test(ai): Wire rag once in ai/rag, test with edge fakes #1329: the Qdrant seam and the RAG test migration. This item's fake stays at the client edge.
- fix(ai): rag chunks stay under the embedder's real token limit, not a four-characters-per-token estimate #1300: chunk sizes.
- feat(review): evidence-first code review — tools find, version-pinned facts ground, models explain and plan, fixes are re-checked #1137: R1, the 2026-09-30 wipe.
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
dan-petty-bot commentedon Oct 8, 2026
Intake placed this item to the backlog: at intake only a critical fix goes into a release; a release start pulls Ready items in, P0 features first.
The default indexing path already triggers cross-project data corruption (KB README overwrites repo README), and failed deletes permanently orphan chunks, silently degrading search results for all users.Correctness of multi-project RAG search is broken by default, and #1389 will make the collision far worse with eight repositories sharing common file names.Fixes span point-ID generation, delete-confirmation flow, purge scoping, force-index cache handling, and atomic cache writes across at least three modules.