Repository navigation
Description
Problem or Motivation
Each devops roadmap intake run on a workstation sends all 1,800 texts of its comparison set to the embedding model again. In three profiled --plan runs (#4404), the embedding call took 133 s, 135 s and 152 s, with 0 memory hits, 0 Valkey hits and 1,800 misses in each run.
There are two causes:
- The Valkey tier of
EmbeddingsEngineis off on a workstation. The defaultvalkey.urlisvalkey://localhost:6379/0, anddevops valkey pinggets "Connection refused" in the devcontainer. The cluster cache Valkey (llm/valkey-devops) admits only thedevopsnamespace (k8s/README.md), so a workstation cannot use it. - The memory tier holds
DEFAULT_RAG_EMBEDDING_CACHE_SIZE= 1,024 entries, which is less than the 1,800 texts of one intake run. A long-lived process also misses on each run.
Between two runs, almost all 1,800 texts stay the same, so almost all of this time is waste.
Proposed Solution & Architectural Design
Keep the embeddings of a workstation between runs, keyed by the existing cache key (the model and the hash of the text). The plan chooses one of these:
- A Valkey in the devcontainer that
valkey.urlalready names (the existing tier, no new cache code). - A persistent local tier of
EmbeddingsEngineunder the data directory.
The plan also sets the size of the memory tier so that it holds one intake comparison set.
Target: the whole intake call takes 1 minute or less (#4404). This item cuts the embedding phase to 5 s or less when 50 or fewer texts changed since the last run.
Target Subsystem
ai
Existing Tool Considered
Valkey is already the cache tier of EmbeddingsEngine, through ValkeyCacheTier. The first option adds no library. The plan states the cost if it chooses the second option.
Source: #4404
Proposed design
Problem statement
Each devops roadmap intake run on a workstation sends all 1,800 texts of its comparison set to the embedding model again, and the embedding phase takes 133 to 152 s with no memory or Valkey hits. The Valkey tier of EmbeddingsEngine has no server at the default valkey.url, and the memory tier holds 1,024 entries, fewer than one comparison set. The change ships valkey-server in the devcontainer image, starts it from the post-start lifecycle on the loopback address that valkey.url names, and raises the memory tier to 2,048 entries, so a run embeds only the texts that changed since the last run.
Acceptance criteria
Requirement: Memory tier holds one comparison set
The default in-memory embedding cache MUST hold at least 1,800 entries.
Scenario: Default cache size covers one intake set
- WHEN The default embedding cache size is read and 1,800 distinct keys are stored in the memory tier.
- THEN The memory tier holds all 1,800 entries and evicts none of them.
Requirement: The devcontainer image ships the Valkey server
The devcontainer image build MUST install the valkey-server binary from the distribution package.
Scenario: The image build names valkey-server
- WHEN A test reads the apt install list of the final stage of
.devcontainer/Dockerfile. - THEN The list names
valkey-server.
Requirement: Post-start starts the workstation cache
devops devcontainer post-start MUST start valkey-server on the loopback host and port of valkey.url, with no persistence, when no server answers there.
Scenario: The post-start plan starts the cache
- WHEN A test builds the post-start plan with the default
valkey.urlofvalkey://localhost:6379/0. - THEN The plan holds one
valkey-serverrequest that names--bind 127.0.0.1,--port 6379,--save ""and--appendonly no, with the condition that no Valkey answers at the URL.
Requirement: A running Valkey is left alone
The post-start lifecycle MUST NOT start a second Valkey when a server answers at valkey.url.
Scenario: A port-forward already serves the URL
- WHEN A server answers PING at
valkey.urlwhen the post-start lifecycle runs. - THEN The lifecycle starts no
valkey-serverprocess and reports that the cache already runs.
Requirement: A missing valkey-server does not fail post-start
The post-start lifecycle MUST complete with no error when valkey-server is not on PATH.
Scenario: An older image has no valkey-server
- WHEN
valkey-serveris not on PATH during the post-start lifecycle. - THEN The lifecycle reports that the cache is not installed and returns its other actions with no error.
Requirement: Second intake run reads embeddings from the cache
A second intake run over unchanged texts MUST send no text to the embedding model.
Scenario: Two intake runs with the same comparison set
- WHEN Two intake runs embed the same 1,800 texts through one configured Valkey tier.
- THEN The second run sends no text to the model and counts 1,800 cache hits.
Requirement: A changed text is embedded again
The cache MUST send a text to the embedding model again only when its text or the embedding model changed.
Scenario: Fifty texts change between two runs
- WHEN A second intake run holds 50 changed texts out of the 1,800 texts of the set.
- THEN The run sends 50 texts to the model and reads 1,750 from the cache.
Requirement: An unreachable Valkey tier keeps the run working
An intake run MUST complete on the memory tier alone when the Valkey tier does not answer.
Scenario: Valkey refuses the connection
- WHEN The configured Valkey refuses the connection during an intake run.
- THEN The run completes with no error and sends each text to the model once.
Existing Tool Considered
Valkey (BSD-3-Clause, open and maintained) covers the need and is already in use: EmbeddingsEngine reads and writes every vector through ValkeyCacheTier, so the change adds no library and no cache code. The alternatives check does not run on a perf item (CONTEXT.md:110). What Valkey lacks on a workstation is a running instance: the default valkey.url is valkey://localhost:6379/0 (src/devops_cli/config/defaults.py:663) and the cluster cache Valkey admits only namespace devops (k8s/README.md:240). The change adds Debian's valkey-server package to the devcontainer image's apt step and starts it from devops devcontainer post-start, so the cost is one package in the image and one lifecycle task, with no cache code to keep.
Key questions
- Is the cluster cache Valkey reachable from a workstation?: Not directly.
valkey-devops-perimeteradmits namespacedevopson TCP 6379 andmonitoringon the exporter port 9121, andllm-default-perimeterleaves the pods out, so a workstation cannot dial the cluster instance. A person can reach it throughkubectl port-forward, which no policy limits and which needs the cluster andvalkey.password; that is not the default for a workstation (perf(roadmap): intake's embeddings are cached in a password-protected valkey in the cluster, so a settled item costs no embedding request on the service's next round #1655). [sources: k8s/README.md:240, openspec/changes/archive/2026-10-29-1655-intake-embedding-valkey/design.md:26] - Which cache tier keeps intake embeddings between CLI runs on a workstation?: The existing Valkey tier through
ValkeyCacheTier, over a localvalkey-server, with no new tier and no new library.EmbeddingsEnginealready reads and writes every vector through the tier, which fails soft behind its breaker, and its key holds the model and the hash of the text, so an unchanged text is a hit in the next process. (best practice) [sources: src/devops_cli/ai/rag/embeddings.py:553, src/devops_cli/ai/rag/embeddings.py:635, src/devops_cli/valkey/cache.py:70, k8s/README.md:240]- Chosen: A Valkey in the devcontainer through the existing tier. It reuses
ValkeyCacheTierand its breaker, and adds no library and no cache code. The cluster cache Valkey admits only namespacedevops, so the workstation needs its own instance. - Rejected: A persistent local tier under the data directory. It builds and keeps a cache that the project owns, with eviction, locking and a file format, for a need that Valkey already covers.
- Rejected: Raise the memory tier only. A new process starts with an empty memory tier, so it does not keep embeddings between runs.
- Chosen: A Valkey in the devcontainer through the existing tier. It reuses
- How does the devcontainer start the Valkey?: The devcontainer image installs Debian's
valkey-serverpackage in its apt step, anddevops devcontainer post-startstarts it in the background on the loopback host and port ofvalkey.urlwhen no server answers there. The workspacedevcontainer.jsonnames the published image and holds nobuildand nofeatures, so a compose file or a feature would change the shape thatdevcontainer-workspace-imagefixes; the image is the only build definition, and post-start already starts a background service. (best practice) [sources: .devcontainer/devcontainer.json:14, src/devops_cli/commands/devcontainer.py:1095, openspec/specs/devcontainer-workspace-image/spec.md:9, openspec/specs/devcontainer-image-tools/spec.md:4, https://packages.debian.org/sid/database/valkey-server]- Chosen: Debian valkey-server in the image, started by post-start. The image is the only build definition and already installs system packages with apt; post-start runs on every container start and already spawns a background service; the binary needs no image pull and no container runtime, so it works offline.
- Rejected: A docker-compose service file. The workspace configuration names the published image and holds no build and no features, and a compose file would change that shape for this repository and for every child repository.
- Rejected: The valkey/valkey container through the devcontainer's Docker. It needs an image pull at the first start and the nested Docker daemon, where the image can ship the binary instead.
- Rejected: A documented docker run command. Each person must run it, and a missed step brings back the 133 to 152 s embedding phase.
- What size holds one intake comparison set in the memory tier?: Set
DEFAULT_RAG_EMBEDDING_CACHE_SIZEto 2,048 entries.EmbeddingsEnginetakes that default for its cache size, so one process holds the 1,800 texts of a comparison set with 248 slots to spare. A vector is a Python list of 1,024 floats, about 32 KiB, so the bound is about 64 MiB, well inside the Service's 3Gi limit. (best practice) [sources: src/devops_cli/config/defaults.py:212, src/devops_cli/ai/rag/embeddings.py:457, CHANGELOG.md:3424, k8s/devops/roadmap-service/deployment.yaml:128]- Chosen: 2,048 entries. It holds the 1,800 texts of one set with headroom; the vectors cost about 64 MiB, and the Service's memory limit is 3Gi.
- Rejected: 1,024 entries, the current value. It is less than the 1,800 texts of one run, so a long-lived process misses on each run.
- Rejected: No bound. A long-lived process would grow with no limit.
- Does the cache key already separate one model and one text from another?: Yes. The memory key is the SHA-256 of the model and the text after the model's task prefix, and the Valkey key is the same hash under the embedding prefix, so a changed text or a changed model gives a miss and an unchanged text gives a hit. [sources: src/devops_cli/ai/rag/embeddings.py:133, src/devops_cli/ai/rag/embeddings.py:635]
- Does the workstation Valkey keep its data on disk?: No. It starts with
--save "" --appendonly no, as the cluster cache Valkey does, so it writes no RDB or AOF file. Valkey documents this as the way to turn persistence off for a cache. The devcontainer keeps the process between CLI runs, and a rebuild or restart costs one run. (best practice) [sources: k8s/README.md:240, k8s/llm/valkey-devops.yaml:71, https://valkey.io/topics/persistence/]- Chosen: No RDB or AOF file. The container lifetime covers the need, a restart costs one run, and an extra file adds state that no test needs and that a person must clear.
- Rejected: An append-only file. It writes disk state for each embedding for a restart that rarely happens, and the file grows.
- When does post-start start the cache?: Only when the host of
valkey.urlis loopback and nothing answers there. Avalkey.urlthat names a remote host is left alone, and a server that already answers, such as akubectl port-forward, is not replaced. The task skips with no error whenvalkey-serveris not on PATH, so an image that predates the change keeps working. (best practice) [sources: src/devops_cli/config/defaults.py:663, src/devops_cli/commands/devcontainer.py:1000, src/devops_cli/devcontainer/devcontainer_plans.py:144, openspec/changes/archive/2026-10-29-1655-intake-embedding-valkey/design.md:26]- Chosen: Loopback valkey.url and no answer. The workstation cache serves only a URL that names the local machine, and a port-forward or another server on the port is not replaced.
- Rejected: Always start on port 6379. It starts an unused service in a child repository that names a remote Valkey, and it collides with a port-forward.
- Rejected: Start only in this repository. A child repository uses the same image and lifecycle, and a workspace check is brittle.
Fit
Fits in one pull request.
Suspected block
None.
Dependencies
None.
Activity
dan-petty commentedon Nov 11, 2026
Intake placed this item to the backlog: intake puts every new item in the backlog. A person plans the milestones.
perfprefix of the title gives the type.(ai)scope of the title gives the scope.It saves about 130 s per intake run but does not affect correctness or security.Developers wait less on every intake run, but the feature does not change results.Enabling Valkey in the devcontainer is small; building a persistent local tier and resizing the memory tier is moderate.Both cache intake embeddings in Valkey, but #1655 serves the in-cluster Service while the candidate serves a workstation CLI run.devops-cli-service commentedon Nov 11, 2026
Status set to Ready at 6cf78e7 (see proposed design in issue body).
devops-cli-service commentedon Nov 11, 2026
Released in v0.112.0: https://github.com/dan-petty/devops-cli/releases/tag/v0.112.0
devops-cli-service commentedon Nov 11, 2026
Live since 2026-11-11 14:13 UTC