Repository navigation
Closed
Labels
effort/mediumEffort Mediumpriority/p2-mediumPriority P2: standard worksource/agentFiled by an agenttype/refactorType refactor: a new structure, same behaviorvalue/mediumValue Medium
Description
Friction
- Each fail-soft cache builds its own Valkey client. While Valkey is down, a silent host costs the full
valkey.timeoutfor each new client. - The embeddings engine builds two clients: a probe with a timeout of at most 0.1 s, and a second client with the configured timeout.
- A review and each tool call build a new
CloudflareRadarClient, and each one builds its ownValkeyClient.
Evidence
Checked at main a752a14.
EmbeddingsEngine._init_valkeybuilds a probe client withtimeout=min(float(cfg.timeout), 0.1)and then a second client (src/devops_cli/ai/rag/embeddings.py:456-478).CloudflareRadarClient.__init__builds its ownValkeyClient(src/devops_cli/security/vulnerability_lookup.py:449-463).src/devops_cli/commands/ai_ingest.py:210-212imports the private_resolve_clientof thedevops valkeycommand module.- The default of
valkey.timeoutis 2.0 s. A refused loopback port fails at once (probed: 7 ms). - fix(valkey): one validated URL names every Valkey endpoint, valkey-py dials an address that one check vetted, and the unused cache layer goes #1113 lists this change as its step F. It follows step B, and Decision 4 of fix(valkey): one validated URL names every Valkey endpoint, valkey-py dials an address that one check vetted, and the unused cache layer goes #1113 decides its premise. After the split, fix(valkey): one validated URL names every Valkey endpoint, valkey-py dials an address that one check vetted, and the unused cache layer goes #1113 only tracks its child issues, and no pull request closes fix(valkey): one validated URL names every Valkey endpoint, valkey-py dials an address that one check vetted, and the unused cache layer goes #1113 itself. So this candidate asks for a change that no other issue holds.
Existing tool considered
- valkey-py
ConnectionPoolalready shares connections inside one client. One process-wide client gives the sharing, with no new library. - The breaker with open, cooldown and half-open states is the scope of feat(cli): recovery transitions for adaptive knobs coalesced decrease, valkey breaker, failback #596. This change builds no breaker.
Proposed remedy
- Build one process-wide fail-soft Valkey client with a short connect timeout, shared by the embeddings engine,
CloudflareRadarClientand the library store. - Put the connect timeout in
DEFAULT_VALKEY_CACHE_CONNECT_TIMEOUT_SECONDSindefaults.py, set from a measured loopback connect. Remove the literal 0.1. - Give
devops ai ingesta public way to get the client. - Reset the shared client after each test in
tests/conftest.py.
Acceptance criteria
- The embeddings engine,
CloudflareRadarClientand the library store share one client. A test shows that two engines and one radar client in one process hold the same object. - While Valkey is down, a second cache makes no second connect attempt. A test counts the attempts and finds one.
- The connect timeout is
DEFAULT_VALKEY_CACHE_CONNECT_TIMEOUT_SECONDSindefaults.py, and the literal 0.1 inembeddings.pyis gone. -
tests/conftest.pyresets the shared client after each test, and the reset rule indocs/TESTING.mdcovers it. - The swallowed-failure ceilings of
ai/rag/embeddings.pyandsecurity/vulnerability_lookup.pyfall by the number of swallowed failures that the change removes. - The change builds no breaker, no half-open state and no cooldown.
- Tests run offline.
uv run devops cipasses.
Source: #1113
Proposed design
Problem statement
Each fail-soft Valkey cache in devops-cli builds its own client. While Valkey is down, each new client costs the full configured timeout on a silent host. The embeddings engine builds two clients, and each CloudflareRadarClient builds its own. This change consolidates them into one process-wide client with a short connect timeout, shared by the embeddings engine, CloudflareRadarClient and the library store.
Acceptance criteria
- Criterion 1: The embeddings engine, CloudflareRadarClient and the library store share one client object.
Verification: A test builds two engines and one radar client in one process and asserts they hold the same object. - Criterion 2: While Valkey is down, a second cache makes no second connect attempt.
Verification: A test counts the connect attempts and finds exactly one. - Criterion 3: The connect timeout is DEFAULT_VALKEY_CACHE_CONNECT_TIMEOUT_SECONDS in defaults.py, and the literal 0.1 in embeddings.py is gone.
Verification: grep for the constant name in defaults.py and confirm the literal 0.1 is absent from embeddings.py. - Criterion 4: tests/conftest.py resets the shared client after each test, and the reset rule in docs/TESTING.md covers it.
Verification: Run the test suite and confirm no cross-test leakage of the shared client. Read docs/TESTING.md for the reset rule. - Criterion 5: The swallowed-failure ceilings of ai/rag/embeddings.py and security/vulnerability_lookup.py fall by the number of swallowed failures the change removes.
Verification: Run uv run pytest tests/test_swallowed_failures_ratchet.py and confirm the ceilings are lower. - Criterion 6: The change builds no breaker, no half-open state and no cooldown.
Verification: grep for breaker, half-open and cooldown in the changed files and confirm none are present. - Criterion 7: Tests run offline and uv run devops ci passes.
Verification: Run uv run devops ci in a clean environment and confirm all checks pass.
Key questions
- Where does the embeddings engine build its Valkey clients?: In _init_valkey, it builds a probe client with timeout=min(float(cfg.timeout), 0.1) and then a second client with the configured timeout. [sources: src/devops_cli/ai/rag/embeddings.py:456-478]
- Where does CloudflareRadarClient build its Valkey client?: In init, it builds its own ValkeyClient with a valkey_client parameter defaulting to _DEFAULT_VALKEY. [sources: src/devops_cli/security/vulnerability_lookup.py:449-463]
- How does devops ai ingest get its Valkey client?: It imports the private _resolve_client from the devops valkey command module and calls it directly. [sources: src/devops_cli/commands/ai_ingest.py:210-212]
- Does this change build a circuit breaker?: No. The breaker with open, cooldown and half-open states is the scope of feat(cli): recovery transitions for adaptive knobs coalesced decrease, valkey breaker, failback #596. This change builds no breaker. (proposed) [sources: src/devops_cli/ai/rag/embeddings.py:456-478, src/devops_cli/security/vulnerability_lookup.py:449-463]
- What is the measured loopback connect time that sets the new timeout?: A refused loopback port fails at once, probed at 7 ms. The constant DEFAULT_VALKEY_CACHE_CONNECT_TIMEOUT_SECONDS is set from this measurement. [sources: tests/conftest.py]
- What is the default of valkey.timeout?: The default is 2.0 s. [sources: src/devops_cli/ai/rag/embeddings.py:456-478]
Fit
Fits in one pull request.
Suspected block
None.
Dependencies
None.
Metadata
Metadata
Assignees
Labels
effort/mediumEffort Mediumpriority/p2-mediumPriority P2: standard worksource/agentFiled by an agenttype/refactorType refactor: a new structure, same behaviorvalue/mediumValue Medium
Type
Projects
- StatusShow more project fieldsReady
- StatusShow more project fieldsNew
Activity
dan-petty commentedon Oct 23, 2026
Intake placed this item to the backlog: intake puts every new item in the backlog. A person plans the milestones on the board.
The change improves code structure and resource usage without adding new features.The change reduces resource usage and improves performance but does not fix a defect or security issue.The change helps multiple components share one client and reduces connection costs.The change requires refactoring multiple clients and adding shared logic.fix(cache): one circuit breaker with open, cooldown and half-open sta…
dan-petty commentedon Oct 28, 2026
Status set to Ready at bb46660 (see proposed design in issue body).