Skip to content

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

Closed as not planned
6 of 6 issues completed

Description

@dan-petty

Tracking issue

This issue tracks the steps of the section "Plan" and the cachetools refactor that the comment of 2026-10-08 folded into this issue. One pull request closes each child issue. No pull request closes this issue. This issue closes when every step and the refactor are delivered.

Step B has no child issue, because intake judged it a duplicate of this issue on 2026-10-23 (#1985). It gets its own child issue before work on it starts. Then this issue closes when all of its child issues close.


Rewrite of 2026-10-22. The owner chose valkey-py 6.2.0 as the client, not GLIDE. The earlier text described GLIDE, and this rewrite replaces it. Part 1 shipped as PR #1856 (commit 2d2b155). This text matches the tip 3ef6985 of release/v0.2.39. Every line number cites that tip.

Problem

Part 1 replaced the hand-written RESP client, the connection pool and the protocol parser with valkey-py. ValkeyClient (src/devops_cli/valkey/client.py:131) stays the one seam. The endpoint settings, the k8s writers, the dashboard and the cache callers still carry the defects below.

A result marked "(probed)" comes from the tip source, run offline with loopback sockets only. Every other result comes from reading the tip.

Done in Part 1

  • protocol.py, pool.py and rate_limiter.py no longer exist. client.py is 241 lines over valkey-py.
  • set takes ex= only. ai/rag/library_store.py:273 and commands/valkey.py:197 pass it.
  • commands/ai_runs.py:160 builds the run-index URL with httpx2.URL(scheme="valkey", ...).
  • tests/support/fakes/valkey.py holds the in-memory server (fakeredis FakeServer).

Endpoint parsing and settings

  • valkeys:// connects in plaintext. ValkeyClient.__init__ builds one pool of plain Connection objects for every scheme (client.py:155-167).
  • The /db path is lost. ValkeyConfig ignores it in valkey.url (probed). For runs.index_url, parse_valkey_endpoint returns only a host and a port (client.py:35-50).
  • ValkeyConfig copies a password from valkey.url into valkey.password and keeps it percent-encoded (probed: p%40ss). For runs.index_url, the client drops the password without a message (probed).
  • In valkey.url, a URL that does not parse falls back without an error (probed):
    • port 99999, port abc and an unbracketed IPv6 URL become localhost:6379;
    • unix:///run/valkey.sock becomes the host unix;
    • http://example.com:6379 becomes the host http;
    • the code ignores ?ssl=true and #frag.
  • In runs.index_url, a bad port makes the whole URL the host name (probed). RunIndex.connect passes the URL as the host argument (ai/run_store.py:255-257).
  • valkey.host set to 2001:db8::1 and valkey.port set to 6380 give the stored host 2001:db8::1:6380 (probed). The client reads that string as a host name (probed).
  • valkey.url is a model field (config/settings.py:268). It has no key in config/options.py and no environment variable. The generated table shows - for both (docs/CONFIGURATION.md:93).
  • The help text of DEVOPS_CLI_VALKEY_TIMEOUT gives the default 5.0 (config/env.py:499). The default is 2.0 (config/defaults.py:586).

Egress check

  • The client resolves a name three times. The calls are in the constructor (client.py:154), in _GuardedConnection.connect (client.py:104) and in valkey-py Connection._connect. The check covers only the first two.
  • A rebinding DNS server can answer the third lookup with an address that the check never saw.
  • When a lookup fails and the caller allows private networks, _resolved_addresses returns an empty list. The check then passes (client.py:61-63).
  • No production caller passes allow_private_network. Every Valkey connection therefore runs at the private level, as AGENTS.md section 5 intends for Valkey.
  • validate_destination refuses every link-local address (client.py:79-82). This includes the 169.254.1.2 address that rootless Podman uses to reach its host (http/egress.py:13-15).

k8s writers

  • A detected NodePort or LoadBalancer address reaches devops k8s configure-urls with the scheme http. See commands/k8s/networking.py:129 and k8s/service.py:363 and :373. _resolve_accessible_url keeps that scheme (networking.py:366-380).
  • So valkey.url can become http://<node>:<port>. The settings model reads that value as the host http (probed).
  • The code builds Valkey URLs with the scheme tcp: default_scheme="tcp" (networking.py:510), the NodePort preview (:630) and the port-forward preview (:1005). A test pins the preview (tests/test_k8s_proxy_addressing.py:264-268).
  • configure-urls writes valkey.host as <hostname>:<port> (networking.py:528-531). The hostname has no brackets, so valkey://[2001:db8::5]:6379 gives 2001:db8::5:6379.

Dashboard

  • fetch_valkey_status reads info["server"], info["clients"], info["memory"] and info["stats"] (ui/data_providers.py:629-636). ValkeyClient.info() returns a flat mapping (client.py:195-197). tests/test_valkey.py:209-215 shows the flat shape. The panel therefore shows the version unknown and an uptime of 0.
  • tests/test_ui_dashboard.py:418-441 uses a MagicMock with the nested shape.
  • The panel passes the plaintext field cfg.password (data_providers.py:623). It does not call get_valkey_password (config/settings.py:1225).

Cache callers

  • EmbeddingsEngine._init_valkey builds two clients (ai/rag/embeddings.py:435-441). The first is a probe with a timeout of at most 0.1 s. The second uses the configured timeout.
  • Each CloudflareRadarClient builds its own ValkeyClient (security/vulnerability_lookup.py:457-463). The code builds that class for each review (ai/review/pipeline.py:2377) and each tool call (ai/tools/builtin_tools.py:491).
  • commands/ai_ingest.py:210-212 borrows the private _resolve_client of the CLI module.
  • A refused loopback port fails at once (probed: 7 ms). A silent host costs the full valkey.timeout for each new instance (client.py:163-164). The default is 2.0 s (config/defaults.py:586).

Dead code

  • Only each other and two test files import devops_cli.cache (tiered.py, 345 lines) and devops_cli.ai.cache (valkey_cache.py, 179 lines). The test files are tests/test_cache_tiered.py and tests/test_valkey.py.
  • Nothing reads ai.cache.backend (config/options.py:68, config/settings.py:408, config/env.py:75 and :513-518).

Plan

Six steps. Each step is a child issue, and one pull request closes it. The section "Tracking issue" lists them.

Step Size Needs Tracked as
A. Delete the cache layer S-M none merged: #1909
E. Fix the dashboard S none merged: #1923
B. One validated URL L A merged no child issue yet
C. Vet once, dial the vetted address M B (same PR, or merged before C) #1988
D. k8s writers M B #1990
F. One shared fail-soft client M B and Decision 4 #1992

Rules for the order:

  • A and E do not depend on each other or on the rest.
  • A goes before B. Both edit options.py, env.py, settings.py, defaults.py and constants.py.
  • E goes before B. Both edit ui/data_providers.py:613-626.
  • B and C both edit client.py. Merge them in one PR, or merge C directly after B.
  • D and F follow B. They use the new ValkeyClient and the new valkey.url.

Rules for every pull request:

  • Each step is a separate issue. Its pull request targets main and closes that issue with a closing keyword.
  • 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 closes when every step issue is closed.
  • Each PR updates the record of its own issue, not one shared task file.
  • Each PR regenerates the docs it changes with uv run devops docs generate --sync-readme. Then uv run devops docs check passes.
  • Each PR passes uv run devops ci with 90% coverage or more. A PR that fixes a defect cites the fail-to-pass check.
  • Tests follow docs/TESTING.md. They double only process edges and bind their own loopback listeners. They patch socket.getaddrinfo, as tests/test_valkey.py:111 does. They never resolve an external name.

Steps

Step A. Delete the cache layer

Size: S-M. About 900 lines go. The change is mechanical.

Order: First. It shares config files with B.

Files:

  • Delete src/devops_cli/cache/ and src/devops_cli/ai/cache/.
  • Delete tests/test_cache_tiered.py. Delete TestValkeyCacheProvider and its import (tests/test_valkey.py:18 and :367-483).
  • Remove ai.cache.backend: config/options.py:68 and :187; config/env.py:75, :164 and :513-518; the field AICacheConfig.backend at config/settings.py:408.
  • Remove DEFAULT_AI_CACHE_TTL_SECONDS (config/defaults.py:597), CONST_CACHE_KEY_SEPARATOR (config/constants.py:2405), CONST_CACHE_TIER_* and CONST_CACHE_TIERS (:2407-2412).
  • Keep CONST_CACHE_NAMESPACE_ROOT. ai/run_store.py:39 reads it.
  • Remove the src/devops_cli/cache/tiered.py entry from tests/fixtures/swallowed_failures_ceilings.json:57.
  • Edit the sample class ValkeyCacheProvider in src/devops_cli/ai/knowledge_base/it_domains/tools/valkey.md:96. The page must not name a deleted class.
  • Regenerate docs/ENV_VARS.md:10 and docs/CONFIGURATION.md:198.

Acceptance criteria:

  • This search prints nothing: rg -n 'devops_cli\.cache|devops_cli\.ai\.cache|TieredCache|ValkeyCacheProvider|AI_CACHE_BACKEND|ai\.cache\.backend' src tests docs/ENV_VARS.md docs/CONFIGURATION.md.
  • A test shows that AICacheConfig.model_fields has no backend field.
  • ai/run_store.py still builds INDEX_PREFIX from CONST_CACHE_NAMESPACE_ROOT, and the run-index tests pass.
  • The swallowed-failure ceiling file names no deleted path, and the ratchet tests pass.

Step E. Fix the dashboard

Size: S.

Order: Any time before B. It edits ui/data_providers.py:613-626, as B does.

Files: src/devops_cli/ui/data_providers.py:613-664, tests/test_ui_dashboard.py:418-441, tests/support/fakes/valkey.py.

Acceptance criteria:

  • A test reads INFO through a real ValkeyClient and a loopback listener with a flat INFO reply. It shows version == "8.0.0" and uptime_seconds == 3600.
  • The same reply sets used_memory, connected_clients, total_commands and hit_ratio. The test checks each one.
  • The listener helper _serving_valkey (tests/test_valkey.py:60-92) moves to tests/support/fakes/valkey.py. Both test files use it.
  • A test stores the password where get_valkey_password reads it. It shows that the AUTH command carries that password.
  • tests/test_ui_dashboard.py no longer uses the nested MagicMock INFO dictionary. The offline test test_fetch_valkey_status_failure stays.

Step B. One validated URL

Size: L. About 24 files change.

Order: After A and E. Step C goes in the same PR, or directly after.

Open tools first:

  • pydantic.AnyUrl with UrlConstraints(allowed_schemes=["valkey", "valkeys"], host_required=True) refuses other schemes, a bad port, an unbracketed IPv6 host and a missing host (probed).
  • pydantic accepts five inputs that the repo must refuse (probed). They are userinfo, a fragment, port 0, an unknown query key and a non-integer db.
  • These five checks are the only new code.
  • pydantic returns a non-ASCII host percent-encoded (probed: b%C3%BCcher.example). The client decodes it with urllib.parse.unquote. Then socket.getaddrinfo applies its idna codec (probed).
  • valkey-py already maps the db path and the TLS class. The PR can use its parser or read the fields from pydantic.

Files:

  • src/devops_cli/valkey/client.py: ValkeyClient takes one URL. Delete parse_valkey_endpoint (:35-50).
  • config/settings.py: delete _parse_valkey_url (:213-230), _normalize_valkey_host (:233-252), the fields host, port and db, and the validator of ValkeyConfig (:264-285). Validate runs.index_url (:261) with the same rule.
  • config/options.py (:63-68, :182-187): add VALKEY_URL. Remove VALKEY_HOST, VALKEY_PORT and VALKEY_DB.
  • config/env.py (:68-72, :157-161, :471-500): add DEVOPS_CLI_VALKEY_URL. Remove the three old variables. Correct the timeout help to 2.0.
  • config/defaults.py: delete DEFAULT_VALKEY_HOST (:585). Add DEFAULT_VALKEY_URL. Keep DEFAULT_VALKEY_PORT (:512), which ai_runs.py and networking.py read.
  • config/constants.py:2731-2734: CONST_VALKEY_SCHEMES shrinks to valkey and valkeys.
  • commands/valkey.py: _resolve_client (:36-53) and the options of the nine subcommands ping, info, stats, keys, get, set, flush, backup and cli.
  • Callers: ai/run_store.py:250-257, ui/data_providers.py:613-626, ai/rag/embeddings.py:418-443, security/vulnerability_lookup.py:449-467.
  • commands/k8s/networking.py:528-531: remove the writes of valkey.host and valkey.port. dotted_set raises ConfigurationError for a key that no longer exists (probed).
  • Tests: tests/conftest.py:1046, tests/support/fakes/valkey.py:36, tests/test_valkey.py:653-692, tests/test_k8s_bootstrap.py:295-313 and :369-383, tests/test_k8s_networking.py:505-509, tests/test_ai_subcommands_rag.py:39-40, tests/test_embedding_config_retention.py:17, tests/test_rag_embeddings.py:750-751.
  • Generated docs: docs/CONFIGURATION.md:91-95, docs/ENV_VARS.md:78-81, docs/CLI_REFERENCE.md, docs/commands/valkey.md.

Acceptance criteria:

One parametrised test runs these inputs through the validator. It runs the same inputs as valkey.url, as runs.index_url and as --url. The message of a refusal names the key.

Input Today (probed) After
valkey://example.com:6379/0 accepts accept: host example.com, port 6379, db 0
valkey://example.com/3 ignores db 3 accept: port 6379, db 3
valkey://example.com:6379?db=4 ignores ?db=4 accept: db 4
valkeys://example.com:6380/0 connects in plaintext accept: TLS with hostname check, db 0
valkey://[2001:db8::1]:6379/0 accepts accept: host 2001:db8::1
valkey://2001:db8::1:6379 falls back to localhost:6379 refuse: IPv6 needs brackets
valkey://<masked-user>:<masked-password>@example.com:6379 copies the password to valkey.password refuse: credentials belong in the keyring
valkey://example.com:99999, :abc, :0 the first two fall back to localhost:6379 refuse: bad port
valkey://example.com:6379/notanint ignores the path refuse: db is not an integer
valkey://example.com:6379?ssl=true, #frag ignores both refuse: unknown query key, fragment
redis://, rediss://, tcp://, unix://, http:// with a host reads the host as a name, or connects in plaintext refuse: scheme
localhost:6380 accepts refuse: no scheme
empty or unset uses localhost:6379 valkey.url is DEFAULT_VALKEY_URL; runs.index_url keeps runs local
valkey://bücher.example:6379 keeps the host as written the resolver receives bücher.example

The remaining criteria:

  • A scheme refusal quotes the scheme it read. For a saved value it names the command that rewrites the key: devops k8s configure-urls for valkey.url, devops ai runs connect for runs.index_url.
  • No message contains the password of a refused URL. A loopback server that rejects AUTH shows that no message holds the keyring password.
  • devops valkey ping --url tcp://example.com:6379 exits with a nonzero code. It prints an error that names --url, and no traceback. All nine subcommands take --url. None takes --host, -h, --port or -p.
  • A bad valkey.url in config.yaml does not stop load_settings(). The first Valkey command raises the error and names valkey.url.
  • A valkeys:// URL builds SSLConnection with ssl_check_hostname=True. The library default is False (probed: with the default, the client accepts a certificate for another name). With socket.getaddrinfo patched, a loopback TLS server refuses a certificate for another name. It accepts a certificate for the URL host.
  • This search prints nothing in src and in the generated docs: rg -n 'parse_valkey_endpoint|_parse_valkey_url|_normalize_valkey_host|ENV_VALKEY_(HOST|PORT|DB)|DEVOPS_CLI_VALKEY_(HOST|PORT|DB)|opt\.VALKEY_(HOST|PORT|DB)|DEFAULT_VALKEY_HOST|valkey\.(host|port|db)\b'.
  • The help text of DEVOPS_CLI_VALKEY_TIMEOUT names the value of DEFAULT_VALKEY_TIMEOUT_SECONDS.

Step C. Vet once, dial the vetted address

Size: M.

Order: In the same PR as B, or directly after B. Both edit client.py.

Open tools first:

Files: src/devops_cli/valkey/client.py, tests/test_valkey.py (TestValkeyClientDestination, :95-157), and a helper under tests/support/ that makes a test CA.

Acceptance criteria:

  • The constructor makes no DNS lookup. A test patches socket.getaddrinfo to raise, and the constructor still returns.
  • One dial makes exactly one lookup. A test counts the calls. The name answers one loopback address first and another address second. The client connects to the first address.
  • The client dials the vetted IP literals in answer order, as VettingBackend.connect_tcp does (egress.py:164-184). A test gives two answers. The first refuses the connection and the second accepts it. The client connects.
  • A name with a metadata answer raises ValkeyConnectionError, not SSRFBlockedError, and opens no socket. The same holds for 169.254.169.254 and ::ffff:169.254.169.254 (probed: vet_addresses refuses both).
  • A failed lookup raises ValkeyConnectionError. The message names the host. This holds when the caller allows private networks, so the hole at client.py:61-63 closes.
  • The client dials a link-local address that is not a metadata address, such as 169.254.1.2 (probed: vet_addresses returns it at the private level). The changelog says so.
  • The client judges and dials a numeric spelling such as 2130706433 as 127.0.0.1 (probed).
  • For valkeys://, the TCP connection goes to the vetted literal. The TLS handshake uses the URL host for SNI and for the certificate check. A loopback TLS server with a CA made by cryptography shows three results:
    • the client accepts a certificate for the URL host;
    • the client refuses a certificate for another name from the same CA;
    • the server of the refused handshake records no command.
  • The server certificate needs an AuthorityKeyIdentifier that names the SubjectKeyIdentifier of the CA. Python rejects the certificate without it (probed: "Missing Authority Key Identifier"). The test trusts the CA through SSL_CERT_FILE (probed in process).
  • validate_destination, _resolved_addresses and the allow_private_network argument no longer exist in valkey/client.py. The level is EgressLevel.PRIVATE.

Step D. k8s writers

Size: M.

Order: After B. B already removes the writes of valkey.host and valkey.port.

Files:

  • commands/k8s/networking.py: delete _has_non_default_valkey_port (:446-461) and _should_update_valkey (:464-485). Replace default_scheme="tcp" (:510), the preview scheme (:630) and tcp://localhost (:1005) with valkey:// URLs. Build them with httpx2.URL(scheme="valkey", host=..., port=...). Send valkey.url through _apply_service_url (:296-309), as qdrant.url goes.
  • Tests: tests/test_k8s_networking.py:20, :51-67 and :500-514; tests/test_k8s_bootstrap.py:268-320; tests/test_k8s_proxy_addressing.py:264-268.

Acceptance criteria:

  • configure-urls saves a detected http://192.0.2.7:30637 as valkey://192.0.2.7:30637. It saves a detected http://[2001:db8::5]:30637 as valkey://[2001:db8::5]:30637 (probed: httpx2.URL writes the brackets).
  • A saved valkey://[2001:db8::5]:6379, valkey://[::ffff:192.0.2.5]:6379 or valkey://example.com:6379 survives when detection finds a loopback URL (probed: _should_update_url already returns False for all three).
  • configure-urls replaces a saved loopback URL with a detected loopback URL. A saved valkey://localhost:6380 survives (Decision 5).
  • The NodePort preview and the port-forward preview show valkey://. test_the_valkey_preview_keeps_its_scheme expects valkey://.
  • rg -n 'tcp://|"tcp"' src/devops_cli/commands/k8s/networking.py src/devops_cli/commands/ai_runs.py src/devops_cli/ai/run_store.py src/devops_cli/valkey prints nothing.

Step F. One shared fail-soft client

Size: M.

Order: After B, and after Decision 4.

Files: ai/rag/embeddings.py:418-443, security/vulnerability_lookup.py:449-467, commands/ai_ingest.py:207-216, config/defaults.py, tests/conftest.py, tests/fixtures/swallowed_failures_ceilings.json (:32 and :124), tests/test_rag_embeddings.py, tests/test_security_threat_intel.py, tests/test_library_vector_tier.py.

Acceptance criteria:

  • The embeddings engine, CloudflareRadarClient and 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_SECONDS in defaults.py. The PR sets the value after it measures a loopback connect. The PR removes the literal 0.1 at embeddings.py:435.
  • tests/conftest.py resets the shared client after each test. The reset rule in docs/TESTING.md:164 covers it.
  • The ceilings of ai/rag/embeddings.py (12) and security/vulnerability_lookup.py (8) fall by the number of swallowed failures the PR removes.
  • The PR builds no breaker, no half-open state and no cooldown. feat(cli): recovery transitions for adaptive knobs coalesced decrease, valkey breaker, failback #596 owns them.

Decisions

Each answer below is decided (owner, 2026-10-22: follow best practices). Only a change of this issue reverses an answer.

  1. Schemes (Step B). Refuse redis://, rediss://, tcp:// and unix://. Add no alias. Status: decided.
    • AGENTS.md allows no compatibility alias before 1.0.
    • valkey-py accepts redis://, rediss:// and unix:// (valkey/_parsers/url_parser.py). The repo check must run first.
    • No code in src writes redis://, rediss://, valkeys:// or a Valkey unix:// URL.
  2. Database path (Step B). Refuse a database that is not an integer, such as /notanint. Status: decided.
    • valkey-py reads that path as db 0 and drops the error (url_parser.py, except (AttributeError, ValueError): pass).
  3. Certificate authorities (Steps B and C). Trust the platform CA store only, for valkeys://. Status: decided.
    • valkey-py loads extra CAs only when the caller sets ssl_ca_certs, ssl_ca_path or ssl_ca_data. The code sets none.
    • An operator can trust a private CA through SSL_CERT_FILE (probed in process).
    • Every URL that the repo writes today is plaintext. A CA setting arrives with the first TLS Valkey.
  4. Step F premise. Build F as one process-wide fail-soft client with a short connect timeout, and no breaker. Status: decided.
    • The old reasons for F came from GLIDE: extra threads, endless reconnects and one stderr line. The code no longer uses GLIDE.
    • Two defects remain: two clients in the embeddings engine, and one new client for each radar instance. A silent host costs the full timeout for each instance.
    • The alternative is to drop F and close that part of the issue with a note.
  5. Saved loopback URL with a non-default port (Step D). Keep the rule that valkey://localhost:6380 survives detection. Status: decided.
    • Today _has_non_default_valkey_port keeps it (networking.py:446-461). tests/test_k8s_networking.py:500-514 pins it.
    • Deleting _should_update_valkey with no replacement changes this. _should_update_url replaces any loopback URL with a detected loopback URL (probed).

Related

Pending a person

  • Pending a person: against a real Valkey 8, run uv run devops valkey ping, info, stats, cli INFO server and uv run devops ai runs reindex.
  • Pending a person: with requirepass set on that server, a wrong keyring password gives an authentication error. The right password connects.

Proposed design

Problem statement

The Valkey client code has defects in endpoint parsing, DNS resolution, k8s URL writing, dashboard reporting, and cache management. This tracking issue coordinates the fix across six steps and a cachetools refactor. Each step is a separate pull request. Steps A and E are merged. Steps B, C, D, F and the refactor remain. This issue closes when every child issue closes.

Acceptance criteria

  • Criterion 1: Step A (delete the cache layer) is merged and no reference to the deleted modules remains.
    Verification: Run: rg -n 'devops_cli.cache|devops_cli.ai.cache|TieredCache|ValkeyCacheProvider|AI_CACHE_BACKEND|ai.cache.backend' src tests docs/ENV_VARS.md docs/CONFIGURATION.md. The output is empty.
  • Criterion 2: Step E (fix the dashboard) is merged and the panel reads flat INFO correctly.
    Verification: A test reads INFO through a real ValkeyClient and a loopback listener with a flat INFO reply. It shows version == "8.0.0" and uptime_seconds == 3600.
  • Criterion 3: Step B (one validated URL) is merged and only valkey:// or valkeys:// URLs are accepted.
    Verification: One parametrised test runs the inputs from the Step B table through the validator for valkey.url, runs.index_url and --url. Each refusal names the key. The search rg -n 'parse_valkey_endpoint|parse_valkey_url|normalize_valkey_host|ENV_VALKEY(HOST|PORT|DB)|DEVOPS_CLI_VALKEY(HOST|PORT|DB)' src prints nothing.
  • Criterion 4: Step C (vet once, dial the vetted address) is merged and the client makes exactly one DNS lookup per dial.
    Verification: A test patches socket.getaddrinfo to raise. The constructor still returns. A second test counts the calls and shows one dial makes exactly one lookup.
  • Criterion 5: Step D (k8s writers) is merged and configure-urls saves valkey:// URLs.
    Verification: configure-urls saves a detected http://192.0.2.7:30637 as valkey://192.0.2.7:30637. The search rg -n 'tcp://|"tcp"' src/devops_cli/commands/k8s/networking.py prints nothing.
  • Criterion 6: Step F (one shared fail-soft client) is merged and all cache callers share one client.
    Verification: A test shows that two embeddings engines and one radar client in one process hold the same object. While Valkey is down, a second cache makes no second connect attempt.
  • Criterion 7: The cachetools refactor (refactor(ai): the embedding LRU cache, the webhook replay guard and the Radar memory cache use cachetools, with a bound and a TTL #1993) is merged and the hand-written OrderedDict caches are replaced.
    Verification: Run: rg -n 'OrderedDict' src/devops_cli/ai/rag/embeddings.py src/devops_cli/server/routes/webhooks.py src/devops_cli/ai/harness/compaction.py. The output is empty. The file src/devops_cli/ai/rag/cache.py does not exist.
  • Criterion 8: All generated docs are regenerated and the docs check passes.
    Verification: Run: uv run devops docs generate --sync-readme. Then run: uv run devops docs check. Both pass with no error.

Key questions

  • What client library is chosen for Valkey?: valkey-py 6.2.0. The owner chose it over GLIDE on 2026-10-22. (proposed) [sources: src/devops_cli/valkey/client.py]
  • Which schemes are refused in the URL validator?: Refuse redis://, rediss://, tcp:// and unix://. Add no alias. Only valkey:// and valkeys:// are accepted. (proposed) [sources: src/devops_cli/config/constants.py:2731]
  • What happens to a database path that is not an integer?: It is refused. The validator rejects a non-integer db path such as /notanint. (proposed) [sources: src/devops_cli/valkey/client.py:35]
  • Should the code trust only the platform CA store for valkeys:// URLs?: Yes. Trust the platform CA store only. An operator can add a private CA through SSL_CERT_FILE. (proposed) [sources: src/devops_cli/valkey/client.py:155]
  • What is the approach for the shared fail-soft client in Step F?: One process-wide fail-soft client with a short connect timeout and no breaker. Issue feat(cli): recovery transitions for adaptive knobs coalesced decrease, valkey breaker, failback #596 owns the breaker. (proposed) [sources: src/devops_cli/ai/rag/embeddings.py:435]
  • Should a saved loopback URL with a non-default port survive detection?: Yes. Keep the rule that valkey://localhost:6380 survives detection. A saved loopback URL is replaced only by a detected loopback URL. (proposed) [sources: src/devops_cli/commands/k8s/networking.py:446]
  • What is the default Valkey connect timeout?: 2.0 seconds. The constant DEFAULT_VALKEY_TIMEOUT_SECONDS holds this value. [sources: src/devops_cli/config/defaults.py:586]
  • Does Step B need its own child issue before work starts?: Yes. Intake judged Step B a duplicate of this issue on 2026-10-23 (fix(roadmap): intake judges a split part a duplicate of the issue that its --source names, so the part gets no issue #1985). It gets its own child issue before work on it starts. [sources: src/devops_cli/valkey/client.py]

Fit

Needs splitting into 5 items:

  1. Step B: one validated valkey:// or valkeys:// URL names every Valkey endpoint (no child issue yet, create before work starts)
  2. Step C (fix(valkey): the Valkey client resolves a name once, vets every answer and dials the vetted address #1988): the Valkey client resolves a name once, vets every answer and dials the vetted address
  3. Step D (fix(k8s): configure-urls saves valkey.url as a valkey:// URL built with httpx2.URL, and keeps a saved non-loopback URL #1990): devops k8s configure-urls saves valkey.url as a valkey:// URL built with httpx2.URL
  4. Step F (perf(valkey): the embeddings engine, the threat-intel client and the library store share one fail-soft Valkey client with a short connect timeout #1992): the fail-soft caches share one Valkey client with a short connect timeout
  5. Cachetools refactor (refactor(ai): the embedding LRU cache, the webhook replay guard and the Radar memory cache use cachetools, with a bound and a TTL #1993): the embedding LRU cache, webhook replay guard and Radar memory cache use cachetools

Suspected block

None.

Dependencies

#1990, #1992, #1993

Sub-issues

Sub-issues

6 of 6 Issues completed
Loading 6 sub-issues

Activity

  1. added
    type/security
    scope/k8s
    scope/security
    on Oct 3, 2026
  2. added
    scope/cli
    scope/config
    priority/p2-medium
    on Oct 3, 2026
  3. dan-petty commented on Oct 8, 2026

    @dan-petty
    OwnerAuthor

    Folded here instead of a new issue: the agent filing quota (#1153) is spent for this cycle, and this refactor shares this item's change surface. It is recorded here in full so it is not lost.

    refactor(ai): bounded in-process caches use cachetools, and the unused ai/rag/cache.py is deleted

    Problem

    Checked at release/v0.2.29 (05e9388).

    Proposed remedy

    • Declare cachetools in pyproject.toml.
    • Replace the three hand-written caches with cachetools.LRUCache (or TTLCache where entries expire), kept under the existing locks. The hit and miss counters stay.
    • Bound the Radar in-memory cache with TTLCache(maxsize=..., ttl=<the threat-intel TTL>).
    • Delete ai/rag/cache.py and tests/test_embedding_cache.py.

    Acceptance criteria

    • rg -n 'OrderedDict' src/devops_cli/ai/rag/embeddings.py src/devops_cli/server/routes/webhooks.py src/devops_cli/ai/harness/compaction.py prints nothing, and src/devops_cli/ai/rag/cache.py no longer exists.
    • Eviction at capacity, hit and miss counts and the embedding-cache metrics behave as today; the existing tests pass, moved where needed.
    • A webhook delivery id seen within the cache's capacity is still refused as a replay.
    • The Radar in-memory cache holds at most its bound and drops entries after the TTL, measured with cachetools' timer or refactor(cli): tests control time: time-machine fakes wall-clock reads, and retry and rate-limit waits return at once and are recorded #1320's clock, never wall time.
    • Tests run offline, with fakes only at the HTTP edge (an httpx2 MockTransport, through tests/llm_stream_fakes.route_client or refactor(cli): Unify HTTP and DNS seams with shared fakes #1314's fixture) or the process edge. No test patches a devops_cli name.
    • Each new or changed test runs in under 1 s.
    • changelog.d/<n>.md records the change; CHANGELOG.md is not edited.
    • uv run devops ci passes.

    Related: #1113, #1146, #817, #1320

    Found by the 2026-10-08 client-library audit.

  4. dan-petty commented on Oct 8, 2026

    @dan-petty
    OwnerAuthor

    Linked: #596 and #1317. The owner's 2026-10-03 comment on #596 sets how this item's store and #596's breaker meet, and #1317 repeats it for its seams. Found by the 2026-10-08 backlog review.

  5. added this to the v0.2.39 milestone on Oct 22, 2026
  6. added
    status/in-progress
    on Oct 22, 2026
  7. changed the title [-]fix(valkey): every Valkey endpoint is one validated URL opened by the Valkey project's GLIDE client, and the hand-written RESP stack is deleted[/-] [+]fix(valkey): one validated URL names every Valkey endpoint, valkey-py dials an address that one check vetted, and the unused cache layer goes[/+] on Oct 22, 2026
  8. 11 remaining items

  9. dan-petty commented on Oct 28, 2026

    @dan-petty
    OwnerAuthor

    The proposal at 69636b6 needs splitting into 5 items. A person splits the item into the items below, or replies in a comment or edits the body to keep one item, and the next refine round looks at the item again.

    1. Step B: one validated valkey:// or valkeys:// URL names every Valkey endpoint (no child issue yet, create before work starts)
    2. Step C (fix(valkey): the Valkey client resolves a name once, vets every answer and dials the vetted address #1988): the Valkey client resolves a name once, vets every answer and dials the vetted address
    3. Step D (fix(k8s): configure-urls saves valkey.url as a valkey:// URL built with httpx2.URL, and keeps a saved non-loopback URL #1990): devops k8s configure-urls saves valkey.url as a valkey:// URL built with httpx2.URL
    4. Step F (perf(valkey): the embeddings engine, the threat-intel client and the library store share one fail-soft Valkey client with a short connect timeout #1992): the fail-soft caches share one Valkey client with a short connect timeout
    5. Cachetools refactor (refactor(ai): the embedding LRU cache, the webhook replay guard and the Radar memory cache use cachetools, with a bound and a TTL #1993): the embedding LRU cache, webhook replay guard and Radar memory cache use cachetools
  10. dan-petty commented on Oct 28, 2026

    @dan-petty
    OwnerAuthor

    Premise check: Step B is already on main

    Step B ("one validated valkey:// or valkeys:// URL names every Valkey endpoint") has no open work. Two merged pull requests delivered it:

    Neither issue had a parent. I linked #2026 and #2060 as sub-issues of this issue.

    Evidence at origin/main 4226904

    • src/devops_cli/valkey/endpoint.py holds parse_valkey_url. It uses pydantic AnyUrl with UrlConstraints(allowed_schemes=["valkey", "valkeys"], host_required=True). It adds the checks for userinfo, a fragment, port 0, an unknown query key and a database that is not an integer.
    • ValkeyConfig.endpoint, RunIndex.connect, the --url option of devops valkey, the dashboard, the cache tier and configure-urls call parse_valkey_url. ValkeyClient takes one ValkeyEndpoint.
    • An offline probe sent every input of the Step B table through ValkeyConfig(url=...).endpoint. In the probe, each DNS lookup raises an error. The results:
      • The valid inputs and valkey://bücher.example:6379 give the expected host, port and database. valkeys:// gives tls=True.
      • Every other input raises ConfigurationError. The message names valkey.url and the command that writes it again. No message holds the password of the URL. No input falls back to localhost:6379.
      • An unset or empty valkey.url gives valkey://localhost:6379/0.
      • A valkeys:// client builds a pool of SSLConnection subclasses with ssl_check_hostname=True. A valkey:// client builds a pool of plain Connection subclasses.
      • RunIndex.connect("valkey://example.com:99999", None) raises a message that names runs.index_url and devops ai runs connect.
    • tests/test_valkey.py::TestValkeyUrl pins the table for valkey.url, runs.index_url and --url. It also pins the TLS handshake against a local CA, the refusal of a certificate for another name, the exit without a traceback, and the absence of --host, --port and -p.
    • This search prints nothing: git grep -nE 'parse_valkey_endpoint|_parse_valkey_url|_normalize_valkey_host|ENV_VALKEY_(HOST|PORT|DB)|DEVOPS_CLI_VALKEY_(HOST|PORT|DB)|opt\.VALKEY_(HOST|PORT|DB)|DEFAULT_VALKEY_HOST|valkey\.(host|port|db)\b' origin/main -- src docs.
    • The help text of DEVOPS_CLI_VALKEY_TIMEOUT names DEFAULT_VALKEY_TIMEOUT_SECONDS (2.0).

    State of this tracking issue

    I wrote no code and filed no new child issue. This issue goes back to New.

  11. added
    status/new
    and removed
    status/in-progress
    on Oct 28, 2026
  12. dan-petty commented on Oct 28, 2026

    @dan-petty
    OwnerAuthor

    Closed as not planned: newer issues and merged code supersede this tracking issue (AGENTS.md rule 2).

    Each step of this issue is merged code or is held by a newer open issue:

    No work is left here that #1992 or #1993 does not hold. The sub-issue links stay for the history.

  13. removed
    status/new
    on Oct 30, 2026
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

    priority/p2-mediumscope/cliscope/configscope/k8sscope/securitytype/security

    Type

    No type

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions