Skip to content

feat(ai): RAG points carry the commit and the document class #4921

Open

Description

@dan-petty

Problem or Motivation

The RAG point payload (src/devops_cli/ai/rag/indexer.py) has no commit and no document class. Thus:

  • a hit cannot become a citation at a SHA;
  • records and history sections cannot be filtered out;
  • a superseded ADR looks current.

The indexer skips hidden folders, so the .agents/skills skills are not indexed. The knowledge base is in Qdrant two times.

Proposed Solution & Architectural Design

This is child 13 of #4880, under the brain tracker #4624.

  1. Add these fields to each point: commit (the ingest head of ingest.py), doc_class (document_class() of src/devops_cli/docs/inventory.py), generated_from (the map of feat(docs): generated pages name their source and stay complete #4889) and adr_status (src/devops_cli/roadmap/adr.py). Print them in the retriever context (retriever.py).
  2. Index .agents/skills/**/SKILL.md as an explicit include.
  3. By default, brain search leaves out openspec/changes, docs/agent/archive and test fixtures. It gives an ADR with its status.
  4. The knowledge base comes only from the tree copy (refactor(ai): drop the knowledge base copies of project docs #3917).
  5. Run one reindex. The trigger stays the rag-ingest CronWorkflow (every 3 minutes) after feat(k8s): let Argo Workflows run roadmap pods in devops #4566 fixes it.

Add an OpenSpec spec delta for the project-brain capability (a new capability if no change has added it yet). Update the RAG text of k8s/README.md and ARCHITECTURE.md.

Target Subsystem

AI & Agentic Review Pipeline (RAG index: src/devops_cli/ai/rag/), with the project brain.

Existing Tool Considered

Qdrant payload fields and filters on the existing collection. Cost: about 150 lines plus tests, about 150k tokens and 3 h.

Acceptance Criteria

  • A test indexes a fixture repository, and each point has commit, doc_class and, for a generated page, generated_from.
  • A superseded ADR point has adr_status superseded.
  • A SKILL.md under .agents/skills is indexed.
  • A search with the default filter returns no point of openspec/changes.
  • The knowledge base text is in one Qdrant project.

Dependencies

#4884, #4889, #3917. The scheduled reindex waits for #4566.

Source: #4880

Alternatives check of 2026-11-21: in-use.
The repository already uses this tool.
Tool: qdrant/qdrant (https://github.com/qdrant/qdrant), Apache-2.0, last activity 2026-11-20, maintained.
Reason: Searches found no open tool that computes the project's commit, document class, generated_from map or ADR status; Qdrant, already in use, stores the payload fields and filters on them, while the indexer and retriever changes remain project code.

Covers:

  • Stores arbitrary JSON payload fields on each point
  • Keyword payload indexes filter points before the vector search
  • Reuses the existing collection, so no second store is added

Lacks:

  • Computes no ingest commit SHA, document class or ADR status
  • Holds no generated_from map and no knowledge-base deduplication
  • Indexes no hidden .agents/skills folder and prints no hit context

Proposed design

Problem statement

Add the RAG provenance fields and default filters. The work waits on #4884, #4889 and #3917. The RAG points carry no commit, document class, generated_from map or ADR status. A hit cannot become a citation at a SHA, and a superseded ADR looks current. The indexer skips .agents/skills and indexes the knowledge base twice. The change adds the fields, the default exclusions, the skill include and the single tree-copy knowledge base.

Acceptance criteria

Requirement: Point provenance fields

The indexer SHALL write the ingest commit and the document class to the payload of each point.

Scenario: Fixture point provenance

  • WHEN A test indexes a fixture repository with a fixed ingest commit.
  • THEN Each point payload has that commit in commit and the document_class() value in doc_class.

Requirement: Generated page source

The indexer SHALL write the generated_from source path from the #4889 map to each generated page point.

Scenario: Generated page payload

Requirement: ADR status

The indexer SHALL write the ADR status to the adr_status field of each ADR point.

Scenario: Superseded ADR

  • WHEN A test indexes a fixture ADR whose frontmatter status is superseded.
  • THEN The point payload has adr_status equal to superseded.

Requirement: Skill file indexing

The indexer SHALL index each .agents/skills/**/SKILL.md file as an explicit include.

Scenario: Hidden skill folder

  • WHEN A test indexes a fixture repository with .agents/skills/example/SKILL.md.
  • THEN The index contains a point for that SKILL.md file.

Requirement: Default search exclusions

The default brain search SHALL exclude points under openspec/changes, docs/agent/archive and tests/fixtures.

Scenario: Default search filter

  • WHEN A test indexes the four paths openspec/changes/example.md, docs/agent/archive/old.md, tests/fixtures/example.py and docs/guide.md and runs the default search.
  • THEN The result has the docs/guide.md point and no point from the three excluded paths.

Requirement: Retriever context fields

The retriever SHALL print commit, doc_class, generated_from and adr_status in the context of a hit.

Scenario: Hit context

  • WHEN A test formats a hit with all four fields set.
  • THEN The context text contains each field value.

Requirement: Single knowledge-base source

The indexer SHALL index the knowledge base only from the tree copy and keep it in one Qdrant project.

Scenario: Tree-copy-only knowledge base

  • WHEN A test indexes a fixture tree copy with a knowledge-base document and a bundled copy of the same document.
  • THEN The docs collection has one point for the document, under the tree-copy project.

Requirement: Project-brain spec delta

The change SHALL add an OpenSpec spec delta for the project-brain capability.

Scenario: Spec validation

  • WHEN The change folder is validated with uv run openspec validate --strict.
  • THEN The command exits 0.

Requirement: RAG documentation

The change SHALL update the RAG text in k8s/README.md and ARCHITECTURE.md.

Scenario: Documentation row

  • WHEN The docs row runs with uv run devops ci --check --only docs.
  • THEN The docs row passes.

Requirement: Pending a person after the merge

The owner MUST run one reindex after the merge and confirm the knowledge base is in one Qdrant project.

Scenario: One reindex

  • WHEN The owner runs one reindex after the merge.
  • THEN The docs collection shows one knowledge-base project.

Existing Tool Considered

Qdrant (in-use) covers the storage and filtering of the new payload fields. The alternatives check in the issue body lists what it covers and lacks. The proposal computes commit, doc_class, generated_from, adr_status and default_excluded in the indexer. It indexes .agents/skills/**/SKILL.md, removes the bundled knowledge-base include, and prints the fields in the retriever.

Key questions

  • Which existing tool stores and filters the new point fields?: Qdrant is in use. It stores the JSON payload and filters points on the existing collection. The indexer computes the project-specific values, and the retriever prints them. (best practice) [sources: src/devops_cli/ai/rag/indexer.py, src/devops_cli/ai/rag/retriever.py]
    • Chosen: Qdrant payload fields and filters. The project already uses Qdrant. It stores and filters the new fields on the existing collection.
    • Rejected: Separate metadata database. It adds a second store and a join that the search does not need.
    • Rejected: Filter after vector search. It can return fewer results than the requested limit and cannot use the payload index.
  • What value goes in the commit field?: Use the ingest head SHA that src/devops_cli/ai/rag/ingest.py records for the tree copy. The retriever prints it as the citation commit. (best practice) [sources: src/devops_cli/ai/rag/ingest.py, src/devops_cli/ai/rag/retriever.py]
    • Chosen: Ingest head SHA. It is the commit of the tree copy that the index reads. A citation can name it.
    • Rejected: Current time. It is not a commit and cannot support a citation.
    • Rejected: Per-file git log. It adds a git call for each file. The issue names the ingest head.
  • How does the indexer get doc_class?: Call document_class() from src/devops_cli/docs/inventory.py for each indexed file. Write its value to doc_class. (best practice) [sources: src/devops_cli/docs/inventory.py, src/devops_cli/ai/rag/indexer.py]
    • Chosen: Reuse document_class(). It is the project's single document classifier. The issue names it.
    • Rejected: Duplicate the classifier in the indexer. Two classifiers can disagree and add maintenance.
  • How does the indexer get generated_from?: Use the source path that the feat(docs): generated pages name their source and stay complete #4889 map gives for a generated page. Write it to generated_from; the citation model names the field at src/devops_cli/citation.py:63. (best practice) [sources: src/devops_cli/citation.py:63, src/devops_cli/ai/rag/indexer.py]
    • Chosen: Reuse the feat(docs): generated pages name their source and stay complete #4889 map. The map already names the source of a generated page. The issue names it.
    • Rejected: Derive the source from the file path. It duplicates the map and can disagree with it.
    • Rejected: Leave generated_from out. A generated page needs its source for a citation.
  • How does the indexer get adr_status?: For a file under docs/adr/, read the status with the ADR parser in src/devops_cli/roadmap/adr.py and write it to adr_status. The citation model names the field at src/devops_cli/citation.py:64. (best practice) [sources: src/devops_cli/roadmap/adr.py, src/devops_cli/citation.py:64]
    • Chosen: Reuse the ADR parser. It already reads the ADR frontmatter status.
    • Rejected: Regex the status in the indexer. It duplicates parsing and misses the roadmap ADR rules.
    • Rejected: Leave adr_status out. A superseded ADR would look current.
  • How should the default search exclude paths?: Set a boolean default_excluded payload field in the indexer for openspec/changes/, docs/agent/archive/ and tests/fixtures/. The retriever adds a Qdrant must_not filter on default_excluded: true. (best practice) [sources: src/devops_cli/ai/rag/indexer.py, src/devops_cli/ai/rag/retriever.py]
    • Chosen: Payload boolean default_excluded. The indexer sets it once. The retriever filters exact values before the vector search.
    • Rejected: Path-prefix filter on file_path. Qdrant payload filters match exact values, not path prefixes.
    • Rejected: Post-search filter. It can return fewer results than the limit and wastes the payload index.
  • How should the indexer include .agents/skills?: Keep the .agents directory in the walk. In _is_indexable_file, allow only .agents/skills/**/SKILL.md before the hidden-path check. (best practice) [sources: src/devops_cli/ai/rag/indexer.py]
    • Chosen: Explicit skill include. It indexes the named files and keeps other hidden folders out.
    • Rejected: Unskip all hidden folders. It indexes .git and other hidden state.
    • Rejected: Copy skills to a visible path. It adds a second copy and a sync step.
  • How should the knowledge base stop appearing twice?: Remove the bundled knowledge-base include from _collect_all_indexing_files and index_knowledge_base. Index the tree copy from refactor(ai): drop the knowledge base copies of project docs #3917 only. (best practice) [sources: src/devops_cli/ai/rag/indexer.py, src/devops_cli/ai/kb.py]
    • Chosen: Tree copy only. It gives one source and one Qdrant project.
    • Rejected: Keep both copies. It keeps the duplicate points and two projects.
    • Rejected: Deduplicate by content hash. It still writes two projects and adds a merge step.
  • How do the tests avoid a live Qdrant and embedder?: Use the fake Qdrant and embedder seams in tests/ai/rag/test_rag_ingest.py. [sources: tests/ai/rag/test_rag_ingest.py, src/devops_cli/ai/rag/indexer.py]
  • Should the retriever print the new fields in its context?: Yes. Print commit, doc_class, generated_from and adr_status for each hit. (best practice) [sources: src/devops_cli/ai/rag/retriever.py]
    • Chosen: Print the fields in the context. The issue asks for the fields in the retriever context. A citation needs them.
    • Rejected: Leave the fields out. A hit cannot become a citation at a SHA without them.
  • How does the change validate the spec delta and the RAG docs?: Run uv run openspec validate --strict for the change folder. Run uv run devops ci --check --only docs for the docs row. [sources: openspec/config.yaml, CONTEXT.md]

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

#4884, #4889, #3917

Activity

  1. added
    source/agent
    on Nov 12, 2026
  2. added
    type/feature
    scope/ai
    status/new
    value/medium
    effort/medium
    on Nov 12, 2026
  3. dan-petty commented on Nov 12, 2026

    @dan-petty
    OwnerAuthor

    Intake placed this item to the backlog: intake puts every new item in the backlog. A person plans the milestones.

  4. added
    priority/p2-medium
    on Nov 12, 2026
  5. devops-cli-service commented on Nov 15, 2026

    @devops-cli-service
    Contributor

    Alternatives check: in-use

    Reason: The searches show that Qdrant already stores arbitrary JSON payload on each point and filters vector search by payload conditions, which covers the storage and filtering half of this issue on the collection the project already uses. It does not produce the project-specific values (ingest commit, document_class(), the generated_from map, adr_status), index .agents/skills, or remove the duplicate tree copy, so the indexer and retriever changes remain project code.

    The repository already uses this tool.

    Tool: qdrant/qdrant (https://github.com/qdrant/qdrant)

    • License: Apache-2.0
    • Last activity: 2026-11-14
    • Maintained: yes

    Covers:

    • Stores per-point JSON payload fields such as commit, doc_class, generated_from and adr_status on the existing collection
    • Payload keyword/integer fields can be indexed and filtered, so default exclusions (openspec/changes, docs/agent/archive, fixtures) and adr_status can be applied inside search
    • Upserts and reindexing work against the same Qdrant collection, so no second knowledge-base store is needed

    Lacks:

    • Computing the commit from the ingest head and wiring it into each point
    • Deriving doc_class from document_class() and generated_from from the feat(docs): generated pages name their source and stay complete #4889 map
    • Reading adr_status from the roadmap ADR module and printing it in the retriever context
    • Indexing .agents/skills/**/SKILL.md as an explicit include
    • Removing the duplicate tree copy so the knowledge base has one source

    Tools considered:

    Searches run:

    • Qdrant payload metadata filtering RAG citations document class, results: 5
    • open source tool index documents vector store with metadata commit SHA filtering, results: 5
    • Qdrant payload index keyword field filter by metadata before vector search, results: 5
    • open source indexer git commit metadata per chunk document type RAG citations tool, results: 5

    Sources:

    Checked on 2026-11-15. A person decides what this means for the item. The check changes no label and closes no issue.

  6. devops-cli-service commented on Nov 16, 2026

    @devops-cli-service
    Contributor

    Refine cannot set this item to Ready at fccb781 while the items below stay open. The next refine round looks at the item again when they close, or when a person replies in a comment or edits the body.

  7. devops-cli-service commented on Nov 26, 2026

    @devops-cli-service
    Contributor

    Next step: the open items close, or a person replies in a comment or edits the body. See Dependencies in the section Proposed design of the body.

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

    effort/mediumpriority/p2-mediumscope/aisource/agentstatus/newtype/featurevalue/medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions