Skip to content

fix(ai): each rag-ingest run embeds every file again #7467

Done

Description

@dan-petty

Problem Description

Each run of the rag-ingest Workflow embeds every file again. The incremental indexer (src/devops_cli/ai/rag/indexer.py) skips a file whose content hash is in its cache file, and it reads and writes that file under DEVOPS_CLI_DATA_DIR. The WorkflowTemplate rag-ingest sets DEVOPS_CLI_DATA_DIR=/home/devops/.data on the volume home, which is an emptyDir. So each pod starts with no cache, clones again, and embeds each chunk again.

The CronWorkflow runs every 3 minutes with concurrencyPolicy: Forbid. A run that takes more than 3 minutes is followed at once by the next one, so the ingest embeds the full set without a stop, and the local embedding model (ai.tasks.embedding.model) gets a constant load.

Evidence, 2026-11-27

Expected Behavior

A run after a complete run embeds only the files whose content changed. The skip state outlives the pod: for example, the run compares the content hashes with the points that Qdrant already holds, or keeps the cache file on a volume that outlives the pod. A run with no change ends within one schedule period.

Acceptance Criteria

  • A test: an ingest whose store already holds the points of each file, with no cache file on disk, embeds no chunk.
  • Pending a person or an agent after the release: two runs in a row with no repository change; the second ends in less than 3 minutes and embeds no chunk.

Related

Proposed design

Problem statement

The rag-ingest Workflow embeds every file on each run. The indexer keeps its skip state in a cache file under DEVOPS_CLI_DATA_DIR, and the workflow pod mounts that directory as an emptyDir. Each run starts with no state, clones again and embeds the full workspace again.

Acceptance criteria

Requirement: Skip state comes from the store

The indexer SHALL treat a file as unchanged when the store holds its current content hash, with no cache file on disk.

Scenario: Store already holds every file

  • WHEN a test calls index_workspace on a workspace of two files with a fake store that holds each file's current content_hash, and the cache directory holds no cache file
  • THEN the fake embedder records no call, and the run returns skipped_files 2 and total_chunks 0

Requirement: Changed file embeds again

The indexer SHALL embed a file whose content hash differs from the hash that the store holds.

Scenario: One file changed

  • WHEN a test indexes a workspace of two files with a fake store that holds a stale hash for one file and the current hash of the other
  • THEN the fake embedder records the chunks of the changed file and no chunk of the unchanged file

Requirement: Points of a deleted file are purged

The indexer SHALL delete the points of a file that the store holds and the workspace no longer has.

Scenario: File removed from the workspace

  • WHEN a test indexes a workspace with no cache file, and a fake store holds points for a file that the workspace lacks and reports a non-zero count for its project
  • THEN the fake store records a delete_points_by_files call with the path of the missing file, and the run returns removed_files 1

Requirement: A failed store read stops the run

The indexer MUST stop with the error of the store read and MUST NOT embed every file.

Scenario: Store read fails

  • WHEN a test indexes a workspace with no cache file and a fake store whose payload read raises DevOpsCLIError
  • THEN index_workspace raises that error and the fake embedder records no call

Requirement: Pending a person after the merge

The rag-ingest Workflow MUST end a second run with no repository change in less than 3 minutes and MUST embed no chunk.

Scenario: Two runs in a row after the release

  • WHEN a person watches two rag-ingest runs in a row after the release, with no change in the indexed repositories
  • THEN the second run ends in less than 3 minutes and its log shows no embedded chunk

Existing Tool Considered

No alternatives check has run on this issue. The need is to read the state that the store already holds, and the Qdrant client that the repository already uses (src/devops_cli/ai/rag/qdrant.py) covers it: each point payload carries content_hash, and the indexer already calls scroll_points with with_payload=True (src/devops_cli/ai/rag/indexer.py). The change adds no library. Written cost of the code that the fix adds: about 1 500 tokens to write the store read and its tests, about 400 tokens for each later fix, and about 2 hours of elapsed time.

Key questions

  • Where does the skip state live so that it outlives the pod?: The run reads the content hashes from the points that the store holds for each scanned project. The cache file stays a local record, and the store wins for the projects that the run scans. (best practice) [sources: src/devops_cli/ai/rag/indexer.py, k8s/devops/workflowtemplate-rag-ingest.yaml]
    • Chosen: Read the hashes from the store. The store is already durable, each payload carries content_hash, and the client already reads payloads. No cluster change is needed, and the read also finds the points of deleted files.
    • Rejected: Keep the cache file on a PersistentVolumeClaim. A claim adds a cluster resource with its own lifecycle and a manifest check, and the cache can still disagree with the store.
    • Rejected: Copy the cache file to the object store. It adds a second durable copy of state that the store already holds, and a new client path.
  • Which data does a point payload hold that identifies the version of a file?: _build_chunk_point writes file_path, project_name, content_hash and indexed_at in each point payload, next to the chunk fields. [sources: src/devops_cli/ai/rag/indexer.py]
  • Why does the cache not survive a rag-ingest run?: WorkspaceIndexer keeps cache_file under the data directory. The WorkflowTemplate sets DEVOPS_CLI_DATA_DIR=/home/devops/.data on the home volume, which is an emptyDir. [sources: src/devops_cli/ai/rag/indexer.py, k8s/devops/workflowtemplate-rag-ingest.yaml]
  • Does the store state replace the cache file, or only fill its gaps?: The store state replaces the cache file for the projects that the run scans. The file keeps the state of projects that the run does not scan. (best practice) [sources: src/devops_cli/ai/rag/indexer.py]
    • Chosen: Store wins for the scanned projects. A stale file entry can then never skip a file whose points the store no longer holds.
    • Rejected: File wins where it has an entry. A stale entry hides lost points, and the fix would depend on the file again.
    • Rejected: Remove the cache file. _check_project_points_intact reads it as a fallback, and many tests set it.
  • How does the indexer read the hashes without loading the whole collection?: It pages scroll_points with with_payload=True and the project_name filter, for each scanned project and collection, until a page is short. A client without scroll_points keeps the cache file behavior. (best practice) [sources: src/devops_cli/ai/rag/indexer.py]
    • Chosen: Page scroll_points per project and collection, payload only. The payload read is small next to an embed, and paging bounds the memory of a large collection.
    • Rejected: Read every point of the collection at once. A large collection would hold every payload in memory.
    • Rejected: Skip the store read when the cache file is empty. That is the state of every pod, so the defect stays.

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

None.

Activity

  1. added
    type/bug
    scope/ai
    source/agent
    status/new
    effort/medium
    on Nov 27, 2026
  2. dan-petty commented on Nov 27, 2026

    @dan-petty
    OwnerAuthor
    • Priority: The embedding model gets constant load and each run takes over 70 minutes, causing sustained performance degradation.
  3. added
    value/high
    priority/p1-high
    on Nov 27, 2026
  4. devops-cli-service commented on Nov 27, 2026

    @devops-cli-service
    Contributor

    Next step: the alternatives check records a verdict. See the section Proposed design of the body.

  5. added
    owner/agent
    status/in-progress
    and removed
    status/new
    on Nov 27, 2026
  6. dan-petty commented on Nov 27, 2026

    @dan-petty
    OwnerAuthor

    More evidence, 2026-11-27 23:08 UTC: the runs with no repository change take as long as the first one.

    Run Start (UTC) End (UTC) Duration
    rag-ingest-1795804020 18:27:00 19:40:30 73.5 min
    rag-ingest-1795813020 20:57:00 22:10:52 73.9 min
    rag-ingest-1795817520 22:12:00 running

    The run that started at 19:42 UTC ended before 20:57 UTC. Each new run starts within 90 seconds of the end of the last one. PR #7478 holds the fix.

  7. added
    status/in-review
    and removed
    status/in-progress
    on Nov 27, 2026
  8. removed
    status/in-review
    owner/agent
    on Nov 27, 2026
  9. devops-cli-service commented on Nov 28, 2026

    @devops-cli-service
    Contributor

    Live since 2026-11-28 02:40 UTC

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/p1-highscope/aisource/agenttype/bugvalue/high

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions