Skip to content

feat(rag): Index managed repos, exclude private from unscoped search #1389

Description

@dan-petty

Refreshed plan (2026-10-17, unblocking review)

This section supersedes any text below that conflicts with it.

Decisions

Scope

Delivery

  • One PR, size M. It carries the module, the command, the payload index, the retriever filter, tests and docs.
  • The private filter ships in the same PR as private ingestion, so no private chunk is ever searchable without a project.

Acceptance criteria

These replace four of the body's sections: "One ingestion lane in the Service", "Embedding load", "Reporting" and "Cluster". "One run for one repository" and "Searches leave private repositories out unless they are named" stand as written, with the changes below.

  • devops ai rag ingest runs one pass over service.repos in configured order, one repository at a time. --repo <owner>/<name> (repeatable) runs only those repositories. A value that is not in service.repos fails with a ConfigurationError naming it, before any request. An empty service.repos fails the same way, naming service.repos, before any request or removed-repository cleanup, so a pass run with the wrong configuration deletes nothing.
  • The visibility read goes through the GitHub session (refactor(github): the github session owns transport, ledger, error classes and link pagination #983) once that lands, and through run_gh until then. It never makes a bare gh call.
  • Removed-repository cleanup runs at the start of every pass, including --repo passes. It compares the pass's recorded state with service.repos. It touches only projects the pass recorded, never a workstation-indexed project.
  • The checkout, cache and state.json sit under repos/<owner>/<name> in data.rag_dir. They are resolved with safe_resolve_subpath, and a path outside that directory or a forbidden system path is refused, as _resolve_roadmap_repo_path does. Nothing is written under the roadmap clone's <data dir>/roadmap/.
  • state.json is written atomically, using the same write fix(ai): the rag index keeps each project's chunks apart, deletes a removed file's points before forgetting it, and refills a project its collection lost #1388 gives the index cache.
  • If qdrant.url is not set in the configuration file or the environment, the command fails with a ConfigurationError naming qdrant.url before any request or clone. It never uses the http://localhost:6333 default (fix(config): service clients use only configured urls and never fall back to an unconfigured localhost default #1165).
  • A failed repository logs one ERROR record naming the repository, the head it tried and the error. The record has a traceback, except for a ConfigurationError (fix(roadmap): the roadmap service logs each failed job's own error with its repository, and a configuration error without a traceback #1365). The pass continues with the next repository.
  • Each repository's run is one trace_span, and counts devops_cli_rag_ingest_runs_total{repo,result} in GLOBAL_METRICS, with result either success or error.
  • The help text is in src/devops_cli/lang/en/help.py, and devops docs generate --sync-readme refreshes the CLI reference.
  • docs/cheatsheets/ai_and_rag.md says what the pass indexes. It also says that devops ai rag clear empties the pass's projects and the next pass refills them, and that a working tree should not be indexed under <owner>/<name>.
  • Tests: the body's Tests section stands (offline, each test under 1 s, no devops_cli name patched, test(cli): tests double only process edges and mirror the source tree #1307, with real git against file:// bare remotes and a fake Qdrant client, embedder and gh runner passed in through arguments), with these changes:
    • the router case moves to the cluster lane;
    • the case "a repository worker and the lane run on one repository at the same time" becomes "a pass leaves a roadmap clone of the same repository under <data dir>/roadmap/ untouched";
    • new: --repo naming a repository outside service.repos fails before any request;
    • new: an empty service.repos fails before any request and leaves a recorded project's points in place;
    • new: when one repository fails, the next is still indexed, and the command exits 1 naming the failure.
  • uv run devops ci passes.
  • Pending a person, after merge, from a workstation with their own credentials:
    • uv run devops ai rag ingest reports one first index per repository and exits 0;
    • devops ai rag status shows the points;
    • a second run straight after embeds nothing;
    • after a push that edits, deletes and renames a file, a re-run makes devops ai rag query "<text of the edit>" --project <owner>/<name> return the new text, and the deleted file's text no longer comes back;
    • a phrase from a private repository comes back only with --project.

Current references (main 3dd7fa6)

Dependencies and order


Problem

Nothing ingests repositories.

The roadmap Service already has most of what a watcher needs.

  • It receives HMAC-verified GitHub deliveries (src/devops_cli/server/routes/webhooks.py), which feat(service): one webhook router verifies each provider its own way, parses a typed payload and delivers each event only to the consumers subscribed to it #1386 turns into typed events delivered to the consumers that subscribe to them.
  • It polls every repository every 300 s (src/devops_cli/server/service.py:258-277; DEFAULT_SERVICE_POLL_INTERVAL_SECONDS, src/devops_cli/config/defaults.py:963).
  • It keeps a PVC at /home/devops (k8s/devops/roadmap-service/deployment.yaml, pvc.yaml).
  • It authenticates git as the machine account through gh auth git-credential (Dockerfile:36-37; ADR 0002, repo scope). With that, it already clones the two private managed repositories for close and refine (src/devops_cli/roadmap/run.py:184-251).

Push deliveries already reach the Service.

The Service cannot reach Qdrant, and the cluster Jobs must not.

  • k8s/README.md:326: "Commands that need Qdrant, Prometheus, Grafana, Argo CD or a repository checkout do not run there yet."
  • devops-default-perimeter selects every pod in namespace devops (podSelector: {}, k8s/devops/networkpolicy.yaml:10). It allows egress to DNS, the gateway on 4000, the collector and public 443 only (:14-55).
  • llm-default-perimeter, which covers the Qdrant pod, admits only namespace llm, monitoring and Traefik (k8s/llm/networkpolicy.yaml:22-38).
  • The ConfigMap template has no qdrant block (k8s/devops/configmap.example.yaml), so qdrant.url is the http://localhost:6333 default (defaults.py:197; fix(config): service clients use only configured urls and never fall back to an unconfigured localhost default #1165).
  • The cluster Jobs read the same ConfigMap, and the same Secret through envFrom (k8s/devops/cronjob.yaml:48-50, k8s/devops/roadmap-service/deployment.yaml:58-60).
  • Qdrant's client waits up to 300 s per attempt by default (DEFAULT_QDRANT_TIMEOUT_SECONDS, defaults.py:372). If a pod got a Qdrant URL that its NetworkPolicy blocks, its RAG lookups would wait out that timeout instead of failing at once.
  • Secret devops/devops-cli carries no Qdrant key (src/devops_cli/k8s/cluster_secrets.py:223-248).
    • The only Qdrant key is the instance's master key, llm/qdrant-api-key (:181-194).
    • Open WebUI keeps its own collections in the same instance (k8s/llm/values-open-webui.yaml:33-36).

Why not a row in the roadmap due table.

  1. Every row runs after _open_roadmap (run.py:870), which needs .github/roadmap.toml and the board. Ingestion needs only git and Qdrant.
  2. Rows run in each repository's own worker thread (service.py:243-245), so up to eight repositories would index at once. A consumer on feat(service): one webhook router verifies each provider its own way, parses a typed payload and delivers each event only to the consumers subscribed to it #1386's default per-repository workers would do the same, which is why this one runs on one shared worker.
    • Each embedding call runs up to ai.gateway_concurrency.embedding requests on its own pool (src/devops_cli/ai/rag/embeddings.py:964-968). The default is 4, and the live ConfigMap doesn't set it.
    • Those requests go to bge-m3:latest on ollama-48gib-slow (k8s/llm/gateway/configmap.yaml:53-59). That tier runs one request per model at a time (OLLAMA_NUM_PARALLEL=1, k8s/llm/profiles/ollama-profiles.yaml:471-472). Ollama's FAQ describes the setting as "The maximum number of parallel requests each model will process at the same time".
    • The same tier serves devops-background, the roadmap jobs' model.
  3. A first index of this repository is about 20,000 chunks at 910b823 (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 that tier). As a row, it would hold up the repository's other jobs for that long.
  4. The roadmap clone tracks the default branch (run.py:244-291). A second thread running git in that clone would collide on its locks.

Why not a separate Deployment. It would need all of these, only to get the isolation that one more thread in the existing process already gives:

  • its own webhook route and HMAC secrets (service.py:325-351);
  • its own poll tick, GitHub token, PVC and NetworkPolicy;
  • its own Argo CD resources;
  • a second webhook on every repository.

The index isn't ready for many repositories.

Private repositories would leak into unscoped searches.

  • Two of the eight managed repositories are private (feat(roadmap): onboard checks a repository for the roadmap jobs #1359).
  • A search names no project unless its caller passes one (src/devops_cli/ai/rag/retriever.py:63-79). The callers that pass none:
  • All of them search through SemanticRetriever; investigate_rag_context builds one at ai/rag/investigator.py:247.
  • A generic question asked while working on a public repository would get private chunks back, and these could be quoted into public GitHub text. AGENTS.md:28 forbids exposing private content.

Acceptance criteria

One ingestion lane in the Service, as a consumer on #1386

  • With service.rag.enabled: true (default false), the Service declares a rag-ingest consumer on feat(service): one webhook router verifies each provider its own way, parses a typed payload and delivers each event only to the consumers subscribed to it #1386. It takes default-branch push events and the poll tick. With the setting off, the consumer isn't declared, and a push gets no_subscriber.
  • A shared worker. This item adds the router's shared-worker mode: a consumer may declare one worker instead of one per subject. Its batch carries the subjects that became due since its last batch, and rag-ingest works through them one at a time, in service.repos order. The worker's job series carry consumer="rag-ingest" and an empty repo; per-repository results are this item's own metrics (Reporting).
  • A repository becomes due on every poll tick, and on every default-branch push the router delivers for it. Webhooks only cut latency (ADR 0003): the next tick catches a missed or dropped delivery.
  • /healthz reports unhealthy if the shared worker dies, as it does for any router worker (service.py:295-304).
  • Drain waits for the current run within drain_timeout_seconds (service.py:306-322). The next start resumes an interrupted run.
  • DEFAULT_DUE_TABLE and service_job are unchanged, and ingestion never opens the roadmap store.

One run for one repository. A new module, src/devops_cli/ai/rag/ingest.py, takes the remote URL, a git runner, a GitHub runner and the indexer as arguments. The Service passes https://github.com/<owner>/<name>.git, as ensure_checkout(remote_url=...) does (run.py:184-196).

Embedding load

  • The ConfigMap template sets ai.gateway_concurrency.embedding: 1. Each embedding call then sends one request at a time (embeddings.py:964-968), and the lane is a single thread.

Searches leave private repositories out unless they are named

  • A search without a project adds a must_not condition on visibility = private (retriever.py:63-79, src/devops_cli/ai/rag/qdrant.py:85-93).
  • A search with a project searches that project, whatever its visibility.
  • Points without visibility, such as workstation indexes and the knowledge base, are unaffected.
  • The condition lives in SemanticRetriever, so it covers every caller listed under Problem, review first.

Reporting

Cluster: only the Service's pods reach Qdrant

  • k8s/devops/roadmap-service/deployment.yaml sets DEVOPS_CLI_QDRANT_URL to http://qdrant.llm.svc.cluster.local:6333, and DEVOPS_CLI_QDRANT_API_KEY from Secret devops/roadmap-service-qdrant. The ConfigMap gets no qdrant block, so cluster Jobs still have no Qdrant URL and no key.
  • cluster_secrets.py gains Secret devops/roadmap-service-qdrant:
    • its one key, DEVOPS_CLI_QDRANT_API_KEY, comes from keyring qdrant_api_key and is adopted from llm/qdrant-api-key api-key;
    • pushing it restarts roadmap-service;
    • the Cluster Secrets table in k8s/README.md lists it.
  • k8s/devops/roadmap-service/networkpolicy.yaml gains a NetworkPolicy, roadmap-service-egress-qdrant. It selects app.kubernetes.io/name: roadmap-service and allows egress to namespace llm on TCP 6333. The peer is namespace-selector-only, as the gateway rule's is (k8s/devops/networkpolicy.yaml:25-33). devops-default-perimeter is unchanged; because policies add up, Jobs still cannot reach Qdrant.
  • k8s/llm/networkpolicy.yaml gains a NetworkPolicy that selects app.kubernetes.io/name: qdrant and admits namespace devops on TCP 6333.
  • Both files are already listed in _MANIFESTS_BY_STACK (src/devops_cli/commands/k8s/stack_lifecycle.py:168-194) and in the kustomizations Argo CD syncs. A test checks that both new policies sit in files that both lists name, which is the miss fix(k8s): deploy-stack applies the llm gateway policy and narrows its egress #795 records for the gateway policy.
  • The ConfigMap template sets service.rag.enabled: true and ai.gateway_concurrency.embedding: 1. render_devops_configmap_content (src/devops_cli/k8s/configmap.py:23-58) still renders and validates it, and a render test checks both values.
  • If service.rag.enabled is set but qdrant.url or its key is not configured, the lane logs one ERROR at start naming the setting, and ingests nothing. The roadmap workers run as before. The lane never falls back to localhost (fix(config): service clients use only configured urls and never fall back to an unconfigured localhost default #1165).
  • k8s/README.md:

Tests (offline; each test under 1 s; no devops_cli name patched, #1307)

  • The edges are passed in through arguments:
  • The cases:
    • the first run indexes every file and records the head;
    • a second run at the same head makes only the visibility read, the ls-remote and two counts, and embeds nothing;
    • a push that edits one file, deletes one and renames one embeds only the edited and the renamed file, and leaves no point for the deleted path or the old name;
    • an embedding failure halfway records no head, and the next run embeds only the files that weren't stored;
    • after git symbolic-ref HEAD refs/heads/<new> in the bare remote, the run follows the renamed default branch;
    • one collection emptied under a matching state.json makes the next run embed every file again;
    • a repository removed from service.repos loses its points and state, while a workstation project in the same collections keeps its points;
    • a private repository's points carry visibility: private. A search without a project doesn't return them, and a search naming the project does;
    • a repository turned public has its payload rewritten; one turned private at the same head is left out of unscoped searches after the next run; internal counts as private;
    • a default-branch push through the router makes the repository due on the shared worker and adds nothing to the roadmap worker's queue. A poll tick makes every repository due. A push to another branch, and other events, don't. With the setting off, a default-branch push gets no_subscriber;
    • a repository worker and the lane run on one repository at the same time without touching each other's directories.
  • uv run devops ci passes.

Pending a person, after merge

  • uv run devops k8s push-secrets --only devops/roadmap-service-qdrant, then uv run devops k8s deploy-stack --stack llm and uv run devops k8s deploy-stack --stack devops.
  • Watch the first index:
    • kubectl -n devops logs deploy/roadmap-service --tail=200 | grep -i rag shows one first index per repository;
    • devops_cli_rag_ingest_behind reaches 0 for every repository;
    • devops ai rag status shows the points;
    • kubectl -n devops get pod -l app.kubernetes.io/name=roadmap-service shows no restart.
  • After the first index, run kubectl -n devops exec deploy/roadmap-service -- df -h /home/devops. The PVC is 1 GiB (k8s/devops/roadmap-service/pvc.yaml:17) and already holds eight roadmap clones. Above 80% used, file a follow-up to grow the volume.
  • While the first index runs, devops_cli_service_jobs_total{result="success"} keeps rising for every repository, and Loki shows no new Roadmap job ... failed records.
  • Push a commit to a managed repository's default branch that edits, deletes and renames a file. Within a minute:
    • devops ai rag query "<text of the edit>" --project <owner>/<name> returns the new text;
    • a query for the deleted file's text returns nothing from it.
  • devops ai rag query "<a phrase from a private repository>" returns no chunk of that repository without --project, and does return it with --project.
  • devops k8s run-job -- ai rag status still finds no Qdrant: Jobs got neither the URL nor the key.

Key questions

  • A row in the roadmap due table, a lane in the Service, or a separate service? Proposed: a lane in the Service. The reasons are under Problem.
  • Why still check the head, when feat(service): one webhook router verifies each provider its own way, parses a typed payload and delivers each event only to the consumers subscribed to it #1386 delivers only default-branch pushes? A re-delivered push, a push the poll already caught, or a force-push back to an indexed commit would each re-index for nothing. The head check costs one ls-remote and two counts.
  • Find changed files with git diff, or with content hashes? Proposed: content hashes, which is the indexer's own incremental path.
    • A diff from the recorded commit needs history that the shallow checkout doesn't keep.
    • A second change-detection path would duplicate the indexer's cache.
    • Hashing one commit's files is quick: this repository has 1,860 tracked files, about 21 MB.
  • Private repositories: include them, skip them, or use a separate collection? Proposed: include them, record visibility, and leave them out of searches that name no project.
    • The request covers every configured repository, and skipping them would drop two of the eight.
    • Qdrant's guide reserves multiple collections for "a limited number of tenants that need strict isolation", which two private repositories arguably are. But a separate collection would make every caller know about it. The filter sits in SemanticRetriever, the one class every search goes through.
    • The checkouts sit on the same PVC as the roadmap clones, under the same machine account.
  • Read the visibility on every tick? Proposed: yes. Otherwise a repository made private without a new push would stay public in the index. It costs about 96 REST requests an hour across eight repositories.
  • Should public sibling repositories show up in searches that name no project? Proposed: yes.
    • Every chunk carries its project in the formatted context (retriever.py:493).
    • AGENTS.md's privacy rule governs what an agent copies into GitHub text.
    • Alternative: default the project to the checkout's origin.
  • What project name? Proposed: <owner>/<name>, the form service.repos uses.
    • A workstation rag index defaults to the directory name (src/devops_cli/ai/rag/indexer.py:48-61), so the Service's projects never collide with a working tree's index.
    • The README asks people not to index a working tree under <owner>/<name>.
  • An opt-in setting? Proposed: service.rag.enabled, false by default, so a workstation devops serve --service starts no embedding. The ConfigMap template turns it on. There is no per-repository list, because the lane covers service.repos.
  • Put the Qdrant URL in the ConfigMap or in the Deployment? Proposed: in the Deployment.
    • Jobs share the ConfigMap, and their egress doesn't reach Qdrant.
    • A URL there would make their RAG lookups wait out the 300 s client timeout, instead of failing on an unset URL.
  • Should the Service hold Qdrant's master key? Proposed: yes for now, under two limits: only the Service's Deployment reads the Secret, and only its pods have egress to Qdrant.
    • The Service also accepts internet-facing webhooks. If it were compromised, the attacker would reach every collection, Open WebUI's included.
    • Qdrant's JWT RBAC (service.jwt_rbac, tokens signed with the API key and scoped to collections) is the least-privilege follow-up. It needs a JWT library and a Qdrant values change, so it is outside this item.
  • A process-wide limit on embedding requests? Proposed: no.
    • With the setting at 1, each call sends one request at a time, and the lane is one thread.
    • Intake's embeds from the repository workers (src/devops_cli/roadmap/intake_model.py:155-160) then wait in Ollama's queue behind at most one lane request. Ollama's FAQ on OLLAMA_MAX_QUEUE: "The maximum number of requests Ollama will queue when busy before rejecting additional requests. The default is 512".
  • Should ingestion pause while roadmap jobs run? Proposed: no.
    • bge-m3:latest and qwen3.8:27b are separate models on the tier, each with its own single slot. They share the GPU without queueing behind each other.
    • Other embedding callers wait for at most one request.
  • A CLI command that runs one pass? Proposed: no. A person can already run devops ai rag index <checkout> --project <name>. A second automatic writer would fight the lane's cache.
  • Grow the PVC? Proposed: not now.
    • A shallow checkout holds one commit.
    • The person-run check reads the volume's usage after the first index. A larger volume becomes a follow-up if it is needed.
  • Who reads the index?

Strategic alignment

Alternatives check of 2026-11-01: not-applicable.
Tool: none found.

Proposed design

Problem statement

Nothing ingests the managed repositories into the RAG index. A person must run devops ai rag index by hand. Two of the eight managed repositories are private, and an unscoped search returns their chunks. This item delivers devops ai rag ingest, which runs one pass over service.repos, records each point's visibility, and leaves private chunks out of searches that name no project. The pass runs from a workstation with the person's own git and GitHub credentials.

Acceptance criteria

Requirement: Default pass over service.repos

The command devops ai rag ingest SHALL run one ingestion pass over service.repos in configured order, one repository at a time.

Scenario: Two configured repositories

  • WHEN service.repos lists repository A then repository B and a person runs devops ai rag ingest with no --repo.
  • THEN The pass indexes A before it starts B and exits 0.

Requirement: Repository selection

The --repo / option SHALL run only the named repositories and MUST reject a value that is not in service.repos with a ConfigurationError before any request.

Scenario: Unknown repository

  • WHEN A person runs devops ai rag ingest --repo foo/bar and foo/bar is not in service.repos.
  • THEN The command raises ConfigurationError naming foo/bar and makes no network request.

Requirement: Empty repository list

An empty service.repos SHALL fail with a ConfigurationError naming service.repos before any request or removed-repository cleanup.

Scenario: Empty service.repos

  • WHEN service.repos is empty and a person runs devops ai rag ingest.
  • THEN The command raises ConfigurationError naming service.repos and deletes no point.

Requirement: Visibility read

The visibility read SHALL use the GitHub session when it exists and MUST use run_gh until then, never a bare gh call.

Scenario: Visibility request path

  • WHEN The pass reads the visibility of a repository.
  • THEN The test's fake GitHub runner receives the request and no bare gh subprocess runs.

Requirement: Removed repository cleanup

The pass SHALL delete the points and state of a repository that the pass recorded and that service.repos no longer lists, and MUST touch no other project.

Scenario: Removed repository beside a workstation project

  • WHEN A pass recorded owner/name, owner/name is removed from service.repos, and a workstation project exists in the same collections.
  • THEN The next pass deletes the points and state of owner/name through delete_points_by_project and keeps every point of the workstation project.

Requirement: Data paths

The checkout, cache and state.json SHALL sit under repos// in data.rag_dir and MUST be resolved with safe_resolve_subpath.

Scenario: Path containment

  • WHEN The pass writes the checkout, cache and state for owner/name.
  • THEN Each path is under data.rag_dir/repos/owner/name, no file appears under the roadmap clone's /roadmap/, and a traversal path is refused.

Requirement: Atomic state write

The pass SHALL write state.json atomically with the index cache's write_json_file(..., atomic=True) and MUST record the head only after the indexer returns.

Scenario: Failed run

  • WHEN The indexer raises an error after embedding part of a repository.
  • THEN No state.json records the new head and the next run embeds the files that were not stored.

Requirement: Qdrant URL required

The command SHALL fail with a ConfigurationError naming qdrant.url before any request or clone when qdrant.url is unset, and MUST NOT use the localhost default.

Scenario: Unset Qdrant URL

  • WHEN Neither the configuration file nor the environment sets qdrant.url and a person runs devops ai rag ingest.
  • THEN The command raises ConfigurationError naming qdrant.url and makes no clone or network request.

Requirement: Failed repository

A failed repository SHALL log one ERROR record naming the repository, the head and the error, with a traceback except for ConfigurationError, and the pass MUST continue with the next repository and exit 1 naming every failure.

Scenario: One repository fails

  • WHEN The first of two configured repositories fails and the second is valid.
  • THEN One ERROR names the first repository with a traceback, the second repository is indexed, and the command exits 1 naming the first repository.

Requirement: Run span and metric

Each repository's run SHALL be one trace_span and MUST count devops_cli_rag_ingest_runs_total{repo,result} in GLOBAL_METRICS.

Scenario: Metric labels

  • WHEN A pass indexes one repository successfully and fails another.
  • THEN Two spans exist and devops_cli_rag_ingest_runs_total has repo and result labels with success and error.

Requirement: Head check

The pass SHALL read the default branch and head with git ls-remote --symref HEAD and MUST skip embedding when the head equals the recorded commit and WorkspaceIndexer.points_intact finds the project's points.

Scenario: Second run at the same head

  • WHEN A second pass runs at the head recorded in state.json and points_intact returns true.
  • THEN The pass makes the visibility read, the ls-remote and two count requests, and embeds nothing.

Requirement: Shallow checkout

The pass SHALL keep a shallow, single-branch checkout at repos///tree and MUST use git clone --depth 1 --single-branch --no-tags on the first run and git fetch --depth 1 origin then git checkout --detach FETCH_HEAD later.

Scenario: First and later checkout

  • WHEN A repository has no checkout, and then its default branch moves.
  • THEN The first run makes a depth-1 single-branch clone and the later run fetches depth 1 and checks out FETCH_HEAD detached.

Requirement: Index with project and visibility

The pass SHALL call WorkspaceIndexer.index_workspace(, project="/", include_kb=False) with its cache under repos// and MUST write visibility on every point.

Scenario: Private repository index

  • WHEN A private repository is indexed.
  • THEN Every point carries visibility: private and CONST_RAG_PAYLOAD_INDEXES gains a keyword index on visibility.

Requirement: Changed files and deletions

The pass SHALL embed only files whose content changed and MUST remove the points of deleted and renamed paths.

Scenario: Edit, delete and rename

  • WHEN A push edits one file, deletes one file and renames one file.
  • THEN Only the edited and renamed files are embedded, and no point remains for the deleted path or the old name.

Requirement: First index and lost points

The pass SHALL index a repository with no state in full and MUST re-index in full a project whose points_intact check fails.

Scenario: No state and emptied collection

  • WHEN A repository has no state.json, or its collection is emptied under a matching state.json.
  • THEN The next pass embeds every file again.

Requirement: Empty repository

The pass SHALL record a repository with no head as empty and MUST NOT treat it as an error.

Scenario: Empty remote

  • WHEN A configured repository has no default-branch head.
  • THEN The pass records it as empty and exits 0 for that repository.

Requirement: Unscoped search filter

A search without a project SHALL add a must_not condition on visibility = private, and a search with a project MUST search that project whatever its visibility.

Scenario: Private and public projects

  • WHEN One private and one public project are indexed and a search runs without a project, then with --project on the private project.
  • THEN The unscoped search returns no private chunk, the scoped search returns the private chunk, and a workstation project without visibility still appears unscoped.

Requirement: Visibility changes

The pass SHALL rewrite visibility on existing points when the read visibility differs from the recorded value and MUST count internal as private.

Scenario: Repository turns private at the same head

  • WHEN A repository recorded public is now private at the same head.
  • THEN The run rewrites visibility on its points and the next unscoped search leaves them out.

Requirement: Help and docs

The command help SHALL live in src/devops_cli/lang/en/help.py and devops docs generate --sync-readme MUST refresh the CLI reference.

Scenario: Generated reference

  • WHEN A person runs uv run devops docs generate --sync-readme.
  • THEN The generated reference includes devops ai rag ingest with its description and --repo option.

Requirement: Cheatsheet

docs/cheatsheets/ai_and_rag.md SHALL say what the pass indexes, that devops ai rag clear empties the pass's projects and the next pass refills them, and that a working tree should not be indexed under /.

Scenario: Cheatsheet text

  • WHEN A person reads docs/cheatsheets/ai_and_rag.md.
  • THEN The file states the pass indexes service.repos, the clear-and-refill behavior, and the working-tree warning.

Requirement: Offline tests

The change SHALL add offline tests under 1 s each that use real git against file:// bare remotes and pass a fake Qdrant client, embedder and gh runner through arguments, without patching a devops_cli name.

Scenario: Test run

  • WHEN A person runs uv run devops ci.
  • THEN The tests pass and no test patches a devops_cli name.

Requirement: CI gate

uv run devops ci SHALL pass.

Scenario: Clean checkout

  • WHEN A person runs uv run devops ci in a clean checkout.
  • THEN The command exits 0.

Existing Tool Considered

No open, maintained tool covers the whole need. The alternatives check of 2026-11-01 returned not-applicable and named no tool, and the closest maintained pieces are the git CLI and qdrant-client: git supplies ls-remote --symref and the shallow clone/fetch (git docs), and qdrant-client supplies set_payload, delete_points_by_project, count and create_payload_index (https://qdrant.tech/documentation/tutorials-operations/incremental-embedding-updates/). Qdrant documents incremental re-embedding as a pipeline a caller writes, not as a library, so the project keeps a thin src/devops_cli/ai/rag/ingest.py and the devops ai rag ingest command on top of its existing WorkspaceIndexer. The written cost is about 250 to 400 lines of code and tests, about 40k tokens to build, about 10k tokens to keep and fix, and 1 to 2 engineer-days.

Key questions

  • Which delivery shape runs the ingestion pass?: A CLI command, devops ai rag ingest, runs one pass from a workstation. Owner decision D11 splits the Argo cluster lane into a deferred item, and the project's own fix(ai): the rag index keeps each project's chunks apart, deletes a removed file's points before forgetting it, and refills a project its collection lost #1388 follow-up list records the same split: the ingestion pass command is feat(rag): Index managed repos, exclude private from unscoped search #1389 and the Argo cluster workflow lane is its follow-up. (best practice) [sources: openspec/changes/archive/2026-10-26-1388-rag-project-isolation/tasks.md:43, openspec/changes/archive/2026-10-26-1388-rag-project-isolation/tasks.md:44]
    • Chosen: CLI command devops ai rag ingest. Owner decision D11. It runs with the person's own credentials, and the cluster lane can reuse the command.
    • Rejected: Service lane in roadmap-service. Owner decision D11 moves this work to the deferred cluster-lane item.
    • Rejected: Separate Deployment. Owner decision D11 moves this work to the deferred cluster-lane item.
  • What project name does a managed repository use?: /, the form that service.repos uses. (best practice) [sources: src/devops_cli/config/settings.py:636, src/devops_cli/ai/rag/indexer.py:894]
    • Chosen: /. It matches service.repos and keeps a workstation index separate.
    • Rejected: Directory name. It collides with a workstation index.
    • Rejected: Repository name only. Two owners can share a repository name.
  • How does the pass find changed files?: It uses the existing WorkspaceIndexer content-hash cache. A shallow checkout keeps no diff history. (best practice) [sources: src/devops_cli/ai/rag/indexer.py:894, openspec/changes/archive/2026-10-26-1388-rag-project-isolation/tasks.md:20]
    • Chosen: Content hashes in the indexer cache. It is the indexer's own incremental path and needs no history.
    • Rejected: git diff from the recorded commit. The shallow checkout does not keep that history.
    • Rejected: A second change-detection cache. It duplicates the indexer's cache.
  • Should the pass check the remote head before indexing?: Yes. It runs git ls-remote --symref HEAD. It skips embedding when the head equals the recorded state and WorkspaceIndexer.points_intact returns true. (best practice) [sources: src/devops_cli/ai/rag/indexer.py:693, openspec/changes/archive/2026-10-26-1388-rag-project-isolation/tasks.md:22]
    • Chosen: Head check with ls-remote and points count. It avoids a re-index for a re-delivered push or a force-push back to an indexed commit.
    • Rejected: Re-index on every run. It wastes embeddings.
    • Rejected: Trust the webhook only. A missed delivery or a force-push would leave the index stale.
  • How does the pass treat private repositories?: It includes them, writes visibility on each point, and adds a must_not filter on visibility = private for searches that name no project. The filter lives in _build_rag_filter_payload/SemanticRetriever, the one path every caller uses. (best practice) [sources: AGENTS.md:28, src/devops_cli/ai/rag/retriever.py:66-82, src/devops_cli/ai/rag/qdrant.py:115-123]
    • Chosen: Include private repositories and filter unscoped searches. The request covers every configured repository, and the filter sits in the one class that every search uses.
    • Rejected: Skip private repositories. It drops two of the eight managed repositories.
    • Rejected: Use a separate collection. Every caller would need to know about it.
  • How often does the pass read repository visibility?: Every run. A repository made private without a push leaves unscoped searches after the next pass. The existing roadmap code already reads visibility on demand through the store, so the pass does the same. (best practice) [sources: src/devops_cli/roadmap/github_store.py:879-883, src/devops_cli/roadmap/refine.py:867-875, src/devops_cli/roadmap/run.py:652]
    • Chosen: Every run. A visibility change needs no push.
    • Rejected: Only when the head changes. A repository made private at the same head would stay public in the index.
    • Rejected: Only when a webhook says so. A webhook delivery can be missed.
  • Where do the checkout, cache and state live?: Under repos// in data.rag_dir, resolved with safe_resolve_subpath. Nothing is written under the roadmap clone. (best practice) [sources: src/devops_cli/config/settings.py:683, src/devops_cli/core/paths.py:34, src/devops_cli/roadmap/run.py:253-271]
    • Chosen: repos// under data.rag_dir. It keeps the pass away from the roadmap clone and its git locks.
    • Rejected: Under the roadmap clone. Two threads would run git in one repository.
    • Rejected: A temporary directory. The cache and state must survive a run.
  • What does the pass do when qdrant.url is unset?: It fails with a ConfigurationError naming qdrant.url before any request or clone. It never falls back to http://localhost:6333. (best practice) [sources: src/devops_cli/config/defaults.py:188, src/devops_cli/config/settings.py:194]
  • How does the pass handle a failed repository?: It logs one ERROR naming the repository, the head and the error, with a traceback except for ConfigurationError. It continues with the next repository and exits 1 naming every failure. That is the project's existing job-error rule (fix(roadmap): the roadmap service logs each failed job's own error with its repository, and a configuration error without a traceback #1365): a configuration-only failure is logged without a traceback. (best practice) [sources: openspec/changes/archive/2026-10-25-1365-roadmap-service-job-errors/tasks.md, src/devops_cli/roadmap/run.py]
    • Chosen: Continue and exit 1. One broken repository must not leave the rest stale.
    • Rejected: Stop the pass. It would leave the other repositories unindexed.
    • Rejected: Exit 0 and log. The command must report failure.
  • What does removed-repository cleanup touch?: At the start of every pass, including --repo passes, it compares the pass's recorded state with service.repos and deletes only projects the pass recorded. delete_points_by_project is the project-scoped, waited delete that fix(ai): the rag index keeps each project's chunks apart, deletes a removed file's points before forgetting it, and refills a project its collection lost #1388 added. (best practice) [sources: src/devops_cli/config/settings.py:636, src/devops_cli/ai/rag/qdrant.py:285, src/devops_cli/ai/rag/qdrant.py:860]
    • Chosen: Only pass-recorded projects. It never deletes a workstation-indexed project.
    • Rejected: Every project in both collections. It would delete a workstation index.
    • Rejected: No cleanup. A removed repository would stay searchable.
  • How is state.json written?: With the atomic write that fix(ai): the rag index keeps each project's chunks apart, deletes a removed file's points before forgetting it, and refills a project its collection lost #1388 gives the index cache: write_json_file(..., atomic=True). A failed run records nothing. (best practice) [sources: openspec/changes/archive/2026-10-26-1388-rag-project-isolation/tasks.md:21, src/devops_cli/output/file_writer.py:112]
  • How does the visibility read reach GitHub?: Through the GitHub session when refactor(github): the github session owns transport, ledger, error classes and link pagination #983 lands, and through run_gh until then. It never makes a bare gh call. The roadmap store already routes its visibility read through run_gh, which keeps the rate limiter. (best practice) [sources: src/devops_cli/github/rate_limiter.py:1862, src/devops_cli/roadmap/github_store.py:879-883, src/devops_cli/roadmap/request_plan.py:437]
    • Chosen: GitHub session, or run_gh until then. It keeps the rate limiter and the session seam.
    • Rejected: Bare gh subprocess. It bypasses the session and the rate limiter.
    • Rejected: Direct HTTP with a new token. It duplicates the GitHub client.
  • What is the disposition of the Argo cluster lane?: It is deferred to a new item. The project's fix(ai): the rag index keeps each project's chunks apart, deletes a removed file's points before forgetting it, and refills a project its collection lost #1388 follow-up list already records the Argo cluster workflow lane as a separate feat(rag): Index managed repos, exclude private from unscoped search #1389 follow-up, and it waits on feat(k8s): the argo workflows controller runs in its own namespace under argo cd and deploy-stack, and a --version workflow measures start-up and api-server load for the go/no-go on moving the roadmap jobs onto it #1535's Argo Workflows go/no-go, feat(service): one webhook router verifies each provider its own way, parses a typed payload and delivers each event only to the consumers subscribed to it #1386's router delivery, chore(service): the roadmap service stays at 0 replicas, and its development is blocked, while its machine account is suspended #1562's Service suspension and a cluster GitHub identity. (best practice) [sources: openspec/changes/archive/2026-10-26-1388-rag-project-isolation/tasks.md:44]
    • Chosen: Defer the cluster lane. Owner decision D11 splits it out, and it cannot be built before those items land.
    • Rejected: Build it in this pull request. It has blocks that only other items and an outside go/no-go can clear.
    • Rejected: Drop it. The owner asked for the index to stay current.

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

None.

Activity

  1. added
    type/feature
    scope/ai
    scope/k8s
    scope/security
    on Oct 8, 2026
  2. dan-petty-bot commented on Oct 8, 2026

    @dan-petty-bot
    Collaborator

    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.

    • Priority: P2-Medium. The owner explicitly requested it on 2026-10-08 and it fills a stated gap, but it is a new feature rather than a defect or security fix.
    • Value: High. Without repository ingestion the RAG system has no project-specific content, making it useless for the eight managed repositories.
    • Effort: High. Requires NetworkPolicy changes, ConfigMap/Secret updates for Qdrant access, a new webhook consumer, poll-based ingestion logic, and git-clone plumbing across multiple k8s and application layers.
  3. added
    status/blocked
    on Oct 11, 2026
  4. dan-petty commented on Oct 11, 2026

    @dan-petty
    OwnerAuthor

    Blocked by #1562: the roadmap Service's machine account is suspended, and the Service is held at 0 replicas. This item develops the Service or can only be checked on it, so it waits until the account is reinstated or the jobs act as a GitHub App.


    Generated by Claude Code

  5. changed the title [-]feat(rag): the roadmap service keeps a rag index of every managed repository's default branch, updated on each default-branch push and each poll[/-] [+]feat(rag): one ingestion pass indexes each managed repository's default branch, and unscoped searches leave private repositories out[/+] on Oct 18, 2026
  6. dan-petty commented on Oct 26, 2026

    @dan-petty
    OwnerAuthor

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

    • Priority: P2-Medium. The item is important but not critical enough for P1 priority.
    • Value: High. This change improves the RAG functionality and search filtering for users.
    • Effort: Medium. The effort is medium as parts of the work were moved to a cluster-lane item.
    • Possible duplicate: feat(k8s): Add an Argo workflow to keep the RAG index current #1653, which may ask for the same change. The model names a CLI command that indexes each managed repository's default branch and filters private repositories from unscoped searches as the change that both ask for. The candidate and item #1653 both ask for a CLI ingestion pass that indexes each managed repository's default branch and filters private repositories. A person closes one of the two if that is so.
  7. dan-petty commented on Oct 28, 2026

    @dan-petty
    OwnerAuthor

    Refine cannot set this item to Ready at 0b76871 until a person answers the questions below. Reply in a comment or edit the body, and the next refine round looks at the item again.

    • A diff from the recorded commit needs history that the shallow checkout doesn't keep.
    • A second change-detection path would duplicate the indexer's cache.
    • Hashing one commit's files is quick: this repository has 1,860 tracked files, about 21 MB.
    • The request covers every configured repository, and skipping them would drop two of the eight.
    • Qdrant's guide reserves multiple collections for "a limited number of tenants that need strict isolation", which two private repositories arguably are. But a separate collection would make every caller know about it. The filter sits in SemanticRetriever, the one class every search goes through.
    • The checkouts sit on the same PVC as the roadmap clones, under the same machine account.
    • Read the visibility on every tick? Proposed: yes. Otherwise a repository made private without a new push would stay public in the index. It costs about 96 REST requests an hour across eight repositories.
    • Every chunk carries its project in the formatted context (retriever.py:493).
    • AGENTS.md's privacy rule governs what an agent copies into GitHub text.
    • Alternative: default the project to the checkout's origin.
    • A workstation rag index defaults to the directory name (src/devops_cli/ai/rag/indexer.py:48-61), so the Service's projects never collide with a working tree's index.
    • The README asks people not to index a working tree under /.
    • Jobs share the ConfigMap, and their egress doesn't reach Qdrant.
    • A URL there would make their RAG lookups wait out the 300 s client timeout, instead of failing on an unset URL.
    • The Service also accepts internet-facing webhooks. If it were compromised, the attacker would reach every collection, Open WebUI's included.
    • Qdrant's JWT RBAC (service.jwt_rbac, tokens signed with the API key and scoped to collections) is the least-privilege follow-up. It needs a JWT library and a Qdrant values change, so it is outside this item.
    • With the setting at 1, each call sends one request at a time, and the lane is one thread.
    • Intake's embeds from the repository workers (src/devops_cli/roadmap/intake_model.py:155-160) then wait in Ollama's queue behind at most one lane request. Ollama's FAQ on OLLAMA_MAX_QUEUE: "The maximum number of requests Ollama will queue when busy before rejecting additional requests. The default is 512".
    • bge-m3:latest and qwen3.8:27b are separate models on the tier, each with its own single slot. They share the GPU without queueing behind each other.
    • Other embedding callers wait for at most one request.
    • A shallow checkout holds one commit.
    • The person-run check reads the volume's usage after the first index. A larger volume becomes a follow-up if it is needed.
    • Chat, the agents, analyze, rag query, and the MCP and agent rag_search tools.
    • Reviews too, until refactor(review): the persona review stage, the legacy segment engine and review-time RAG are deleted, and devops review builds a model client only for the explanation stages #1151 removes review-time RAG.
    • feat(review): evidence-first code review — tools find, version-pinned facts ground, models explain and plan, fixes are re-checked #1137 keeps embeddings for chat, MCP and the KB index. This item doesn't bring RAG back into reviews.
  8. removed
    status/blocked
    on Oct 28, 2026
  9. 7 remaining items

  10. devops-cli-service commented on Nov 5, 2026

    @devops-cli-service
    Contributor

    Status set to Ready at d254410 (see proposed design in issue body).

    Moved to new items: #3589.

  11. changed the title [-]feat(rag): one ingestion pass indexes each managed repository's default branch, and unscoped searches leave private repositories out[/-] [+]feat(rag): Index managed repos, exclude private from unscoped search[/+] on Nov 6, 2026
  12. dan-petty commented on Nov 6, 2026

    @dan-petty
    OwnerAuthor

    The job shortened the title of this item. The summary had 121 characters, and the limit is 60. The type and the scope stay.

    • Before: feat(rag): one ingestion pass indexes each managed repository's default branch, and unscoped searches leave private repositories out
    • After: feat(rag): Index managed repos, exclude private from unscoped search
    • Source of the summary: the background model
  13. added
    status/in-progress
    and removed
    status/ready
    on Nov 7, 2026
  14. added
    status/in-review
    and removed
    status/in-progress
    on Nov 7, 2026
  15. removed
    status/in-review
    on Nov 7, 2026
  16. added a commit that references this issue on Nov 7, 2026
  17. devops-cli-service commented on Nov 7, 2026

    @devops-cli-service
    Contributor
  18. devops-cli-service commented on Nov 7, 2026

    @devops-cli-service
    Contributor

    Live since 2026-11-07 05:06 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/p2-mediumscope/aiscope/k8sscope/securitytype/featurevalue/high

    Type

    No type

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions