Repository navigation
Description
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 A, merged in refactor(valkey): delete the tiered cache, the Valkey cache provider and ai.cache.backend #1909: the cache layer is deleted.
- Step E, merged in fix(ui): the Valkey panel reads the flat INFO mapping and the keyring password #1923: the dashboard reads the flat INFO mapping and the keyring password.
- Step B, no child issue yet: one validated
valkey://orvalkeys://URL names every Valkey endpoint. - 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.
- 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-urlssavesvalkey.urlas avalkey://URL built withhttpx2.URL. - 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.
- 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: the embedding LRU cache, the webhook replay guard and the Radar memory cache use cachetools. v0.2.39 already deleted
ai/rag/cache.pyandai/harness/compaction.py.
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.pyandrate_limiter.pyno longer exist.client.pyis 241 lines over valkey-py.settakesex=only.ai/rag/library_store.py:273andcommands/valkey.py:197pass it.commands/ai_runs.py:160builds the run-index URL withhttpx2.URL(scheme="valkey", ...).tests/support/fakes/valkey.pyholds the in-memory server (fakeredisFakeServer).
Endpoint parsing and settings
valkeys://connects in plaintext.ValkeyClient.__init__builds one pool of plainConnectionobjects for every scheme (client.py:155-167).- The
/dbpath is lost.ValkeyConfigignores it invalkey.url(probed). Forruns.index_url,parse_valkey_endpointreturns only a host and a port (client.py:35-50). ValkeyConfigcopies a password fromvalkey.urlintovalkey.passwordand keeps it percent-encoded (probed:p%40ss). Forruns.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, portabcand an unbracketed IPv6 URL becomelocalhost:6379; unix:///run/valkey.sockbecomes the hostunix;http://example.com:6379becomes the hosthttp;- the code ignores
?ssl=trueand#frag.
- port
- In
runs.index_url, a bad port makes the whole URL the host name (probed).RunIndex.connectpasses the URL as thehostargument (ai/run_store.py:255-257). valkey.hostset to2001:db8::1andvalkey.portset to 6380 give the stored host2001:db8::1:6380(probed). The client reads that string as a host name (probed).valkey.urlis a model field (config/settings.py:268). It has no key inconfig/options.pyand no environment variable. The generated table shows-for both (docs/CONFIGURATION.md:93).- The help text of
DEVOPS_CLI_VALKEY_TIMEOUTgives 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-pyConnection._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_addressesreturns 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_destinationrefuses 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-urlswith the schemehttp. Seecommands/k8s/networking.py:129andk8s/service.py:363and:373._resolve_accessible_urlkeeps that scheme (networking.py:366-380). - So
valkey.urlcan becomehttp://<node>:<port>. The settings model reads that value as the hosthttp(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-urlswritesvalkey.hostas<hostname>:<port>(networking.py:528-531). The hostname has no brackets, sovalkey://[2001:db8::5]:6379gives2001:db8::5:6379.
Dashboard
fetch_valkey_statusreadsinfo["server"],info["clients"],info["memory"]andinfo["stats"](ui/data_providers.py:629-636).ValkeyClient.info()returns a flat mapping (client.py:195-197).tests/test_valkey.py:209-215shows the flat shape. The panel therefore shows the versionunknownand an uptime of 0.tests/test_ui_dashboard.py:418-441uses aMagicMockwith the nested shape.- The panel passes the plaintext field
cfg.password(data_providers.py:623). It does not callget_valkey_password(config/settings.py:1225).
Cache callers
EmbeddingsEngine._init_valkeybuilds 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
CloudflareRadarClientbuilds its ownValkeyClient(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-212borrows the private_resolve_clientof the CLI module.- A refused loopback port fails at once (probed: 7 ms). A silent host costs the full
valkey.timeoutfor 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) anddevops_cli.ai.cache(valkey_cache.py, 179 lines). The test files aretests/test_cache_tiered.pyandtests/test_valkey.py. - Nothing reads
ai.cache.backend(config/options.py:68,config/settings.py:408,config/env.py:75and: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.pyandconstants.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
ValkeyClientand the newvalkey.url.
Rules for every pull request:
- Each step is a separate issue. Its pull request targets
mainand 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. Thenuv run devops docs checkpasses. - Each PR passes
uv run devops ciwith 90% coverage or more. A PR that fixes a defect cites thefail-to-passcheck. - Tests follow
docs/TESTING.md. They double only process edges and bind their own loopback listeners. They patchsocket.getaddrinfo, astests/test_valkey.py:111does. 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/andsrc/devops_cli/ai/cache/. - Delete
tests/test_cache_tiered.py. DeleteTestValkeyCacheProviderand its import (tests/test_valkey.py:18and:367-483). - Remove
ai.cache.backend:config/options.py:68and:187;config/env.py:75,:164and:513-518; the fieldAICacheConfig.backendatconfig/settings.py:408. - Remove
DEFAULT_AI_CACHE_TTL_SECONDS(config/defaults.py:597),CONST_CACHE_KEY_SEPARATOR(config/constants.py:2405),CONST_CACHE_TIER_*andCONST_CACHE_TIERS(:2407-2412). - Keep
CONST_CACHE_NAMESPACE_ROOT.ai/run_store.py:39reads it. - Remove the
src/devops_cli/cache/tiered.pyentry fromtests/fixtures/swallowed_failures_ceilings.json:57. - Edit the sample class
ValkeyCacheProviderinsrc/devops_cli/ai/knowledge_base/it_domains/tools/valkey.md:96. The page must not name a deleted class. - Regenerate
docs/ENV_VARS.md:10anddocs/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_fieldshas nobackendfield. ai/run_store.pystill buildsINDEX_PREFIXfromCONST_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
ValkeyClientand a loopback listener with a flat INFO reply. It showsversion == "8.0.0"anduptime_seconds == 3600. - The same reply sets
used_memory,connected_clients,total_commandsandhit_ratio. The test checks each one. - The listener helper
_serving_valkey(tests/test_valkey.py:60-92) moves totests/support/fakes/valkey.py. Both test files use it. - A test stores the password where
get_valkey_passwordreads it. It shows that theAUTHcommand carries that password. tests/test_ui_dashboard.pyno longer uses the nestedMagicMockINFO dictionary. The offline testtest_fetch_valkey_status_failurestays.
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.AnyUrlwithUrlConstraints(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 withurllib.parse.unquote. Thensocket.getaddrinfoapplies itsidnacodec (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:ValkeyClienttakes one URL. Deleteparse_valkey_endpoint(:35-50).config/settings.py: delete_parse_valkey_url(:213-230),_normalize_valkey_host(:233-252), the fieldshost,portanddb, and the validator ofValkeyConfig(:264-285). Validateruns.index_url(:261) with the same rule.config/options.py(:63-68,:182-187): addVALKEY_URL. RemoveVALKEY_HOST,VALKEY_PORTandVALKEY_DB.config/env.py(:68-72,:157-161,:471-500): addDEVOPS_CLI_VALKEY_URL. Remove the three old variables. Correct the timeout help to 2.0.config/defaults.py: deleteDEFAULT_VALKEY_HOST(:585). AddDEFAULT_VALKEY_URL. KeepDEFAULT_VALKEY_PORT(:512), whichai_runs.pyandnetworking.pyread.config/constants.py:2731-2734:CONST_VALKEY_SCHEMESshrinks tovalkeyandvalkeys.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 ofvalkey.hostandvalkey.port.dotted_setraisesConfigurationErrorfor 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-313and: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-urlsforvalkey.url,devops ai runs connectforruns.index_url. - No message contains the password of a refused URL. A loopback server that rejects
AUTHshows that no message holds the keyring password. devops valkey ping --url tcp://example.com:6379exits with a nonzero code. It prints an error that names--url, and no traceback. All nine subcommands take--url. None takes--host,-h,--portor-p.- A bad
valkey.urlinconfig.yamldoes not stopload_settings(). The first Valkey command raises the error and namesvalkey.url. - A
valkeys://URL buildsSSLConnectionwithssl_check_hostname=True. The library default isFalse(probed: with the default, the client accepts a certificate for another name). Withsocket.getaddrinfopatched, a loopback TLS server refuses a certificate for another name. It accepts a certificate for the URL host. - This search prints nothing in
srcand 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_TIMEOUTnames the value ofDEFAULT_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:
devops_cli.http.egress.vet_addresses(host, port, level)(egress.py:122-135) is the shared resolve-and-check from fix(security): every HTTP client dials only addresses its egress level allows, checked at the connect and on every redirect #898.- valkey-py has no resolver hook.
Connection._connectcallssocket.getaddrinfoitself. SSLConnectiontakes nossl_context. It setsserver_hostnamefromself.host.- So the build is one
_connectoverride in aConnectionsubclass, with one variant for TLS. - The PR body states the cost in tokens and hours, as AGENTS.md section 1 requires.
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.getaddrinfoto 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_tcpdoes (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, notSSRFBlockedError, and opens no socket. The same holds for169.254.169.254and::ffff:169.254.169.254(probed:vet_addressesrefuses both). - A failed lookup raises
ValkeyConnectionError. The message names the host. This holds when the caller allows private networks, so the hole atclient.py:61-63closes. - The client dials a link-local address that is not a metadata address, such as
169.254.1.2(probed:vet_addressesreturns it at the private level). The changelog says so. - The client judges and dials a numeric spelling such as
2130706433as127.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 bycryptographyshows 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
AuthorityKeyIdentifierthat names theSubjectKeyIdentifierof the CA. Python rejects the certificate without it (probed: "Missing Authority Key Identifier"). The test trusts the CA throughSSL_CERT_FILE(probed in process). validate_destination,_resolved_addressesand theallow_private_networkargument no longer exist invalkey/client.py. The level isEgressLevel.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). Replacedefault_scheme="tcp"(:510), the preview scheme (:630) andtcp://localhost(:1005) withvalkey://URLs. Build them withhttpx2.URL(scheme="valkey", host=..., port=...). Sendvalkey.urlthrough_apply_service_url(:296-309), asqdrant.urlgoes.- Tests:
tests/test_k8s_networking.py:20,:51-67and:500-514;tests/test_k8s_bootstrap.py:268-320;tests/test_k8s_proxy_addressing.py:264-268.
Acceptance criteria:
configure-urlssaves a detectedhttp://192.0.2.7:30637asvalkey://192.0.2.7:30637. It saves a detectedhttp://[2001:db8::5]:30637asvalkey://[2001:db8::5]:30637(probed:httpx2.URLwrites the brackets).- A saved
valkey://[2001:db8::5]:6379,valkey://[::ffff:192.0.2.5]:6379orvalkey://example.com:6379survives when detection finds a loopback URL (probed:_should_update_urlalready returns False for all three). configure-urlsreplaces a saved loopback URL with a detected loopback URL. A savedvalkey://localhost:6380survives (Decision 5).- The NodePort preview and the port-forward preview show
valkey://.test_the_valkey_preview_keeps_its_schemeexpectsvalkey://. 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/valkeyprints 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,
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. The PR sets the value after it measures a loopback connect. The PR removes the literal 0.1 atembeddings.py:435. tests/conftest.pyresets the shared client after each test. The reset rule indocs/TESTING.md:164covers it.- The ceilings of
ai/rag/embeddings.py(12) andsecurity/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.
- Schemes (Step B). Refuse
redis://,rediss://,tcp://andunix://. Add no alias. Status: decided.- AGENTS.md allows no compatibility alias before 1.0.
- valkey-py accepts
redis://,rediss://andunix://(valkey/_parsers/url_parser.py). The repo check must run first. - No code in
srcwritesredis://,rediss://,valkeys://or a Valkeyunix://URL.
- 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).
- valkey-py reads that path as db 0 and drops the error (
- 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_pathorssl_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.
- valkey-py loads extra CAs only when the caller sets
- 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.
- Saved loopback URL with a non-default port (Step D). Keep the rule that
valkey://localhost:6380survives detection. Status: decided.- Today
_has_non_default_valkey_portkeeps it (networking.py:446-461).tests/test_k8s_networking.py:500-514pins it. - Deleting
_should_update_valkeywith no replacement changes this._should_update_urlreplaces any loopback URL with a detected loopback URL (probed).
- Today
Related
- feat(cli): recovery transitions for adaptive knobs coalesced decrease, valkey breaker, failback #596 (open, v0.2.40) owns the Valkey breaker. Step F must not build one.
- refactor(ai): Valkey, Qdrant and the embedder each have one seam, with shared fakes and contract suites #1317 (open, no milestone) plans a Valkey seam. Its text still cites
_create_socketandpool.py, which Part 1 deleted. A person refreshes that text. - Closed and merged: fix(security): egress guards refuse cloud metadata in every numeric, NAT64 and provider form, classified by ipaddress and one maintained library #897, fix(security): every HTTP client dials only addresses its egress level allows, checked at the connect and on every redirect #898 (
vet_addresses), feat(ci): hand-rolled URL and address parsing failsdevops ci, AGENTS.md makes the library the rule, and reviews stop discarding the findings #1107, fix(k8s): tunnel sync and url setup still overwrite settings they should keep #794 and refactor(valkey): valkey-py replaces the hand-written RESP client, connection pool and protocol parser #1856 (Part 1). - Out of scope: a contract suite for the in-memory Valkey server. It waits for a recorded exchange or a local Valkey (see the docstring of
tests/support/fakes/valkey.py).
Pending a person
- Pending a person: against a real Valkey 8, run
uv run devops valkey ping,info,stats,cli INFO serveranduv run devops ai runs reindex. - Pending a person: with
requirepassset 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 detectedhttp://192.0.2.7:30637as 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:
- Step B: one validated valkey:// or valkeys:// URL names every Valkey endpoint (no child issue yet, create before work starts)
- 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
- 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
- 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
- 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
Sub-issues
Collapse Sub-issuesSub-issues
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsNew
- StatusShow more project fieldsNew
Activity
dan-petty commentedon Oct 8, 2026
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).
OrderedDict, each with its own lock and eviction:_EmbeddingLRUCache(ai/rag/embeddings.py:96-145);DeliveryLRUCache, the webhook replay guard (server/routes/webhooks.py:52-69);ai/harness/compaction.py:95, eviction at:145).ai/rag/cache.py(EmbeddingCache, 97 lines) duplicates_EmbeddingLRUCacheand has no caller insrc; onlytests/test_embedding_cache.pyimports it.security/vulnerability_lookup.py:378).LRUCacheandTTLCacheand is already in uv.lock as a transitive dependency.OrderedDictcaches incache/tiered.pyand the OSV client are not part of this item; they go with 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 and feat(review): dependency advisories and the package inventory come from osv-scanner over the lockfiles, offline, with each advisory's own severity #1146.Proposed remedy
cachetoolsinpyproject.toml.cachetools.LRUCache(orTTLCachewhere entries expire), kept under the existing locks. The hit and miss counters stay.TTLCache(maxsize=..., ttl=<the threat-intel TTL>).ai/rag/cache.pyandtests/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.pyprints nothing, andsrc/devops_cli/ai/rag/cache.pyno longer exists.MockTransport, throughtests/llm_stream_fakes.route_clientor refactor(cli): Unify HTTP and DNS seams with shared fakes #1314's fixture) or the process edge. No test patches a devops_cli name.changelog.d/<n>.mdrecords the change;CHANGELOG.mdis not edited.uv run devops cipasses.Related: #1113, #1146, #817, #1320
Found by the 2026-10-08 client-library audit.
dan-petty commentedon Oct 8, 2026
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.
refactor(valkey): valkey-py replaces the hand-written RESP client, co…
[-]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[/+]refactor(valkey): delete the tiered cache, the Valkey cache provider …
fix(ui): the Valkey panel reads the flat INFO mapping and the keyring…
11 remaining items
fix(roadmap): intake judges a split part a duplicate of the issue tha…
fix(valkey): valkey.url keeps its scheme, so a valkeys url dials tls …
fix(valkey): valkey.url is one validated url, its path names the data…
fix(cache): one circuit breaker with open, cooldown and half-open sta…
dan-petty commentedon Oct 28, 2026
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.
dan-petty commentedon Oct 28, 2026
Premise check: Step B is already on
mainStep B ("one validated
valkey://orvalkeys://URL names every Valkey endpoint") has no open work. Two merged pull requests delivered it:5f36c4cd) delivers fix(valkey): valkey.url keeps its scheme, so a valkeys url dials tls with host name checks #2026. Avalkeys://URL invalkey.urldials TLS with a host name check.12fa20c2) delivers fix(valkey): valkey.url is one validated url, its path names the database, and the separate host, port and db settings go #2060.valkey.urlis one validated URL, and its path names the database. The settingsvalkey.host,valkey.portandvalkey.dbare removed.Neither issue had a parent. I linked #2026 and #2060 as sub-issues of this issue.
Evidence at
origin/main4226904src/devops_cli/valkey/endpoint.pyholdsparse_valkey_url. It uses pydanticAnyUrlwithUrlConstraints(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--urloption ofdevops valkey, the dashboard, the cache tier andconfigure-urlscallparse_valkey_url.ValkeyClienttakes oneValkeyEndpoint.ValkeyConfig(url=...).endpoint. In the probe, each DNS lookup raises an error. The results:valkey://bücher.example:6379give the expected host, port and database.valkeys://givestls=True.ConfigurationError. The message namesvalkey.urland the command that writes it again. No message holds the password of the URL. No input falls back tolocalhost:6379.valkey.urlgivesvalkey://localhost:6379/0.valkeys://client builds a pool ofSSLConnectionsubclasses withssl_check_hostname=True. Avalkey://client builds a pool of plainConnectionsubclasses.RunIndex.connect("valkey://example.com:99999", None)raises a message that namesruns.index_urlanddevops ai runs connect.tests/test_valkey.py::TestValkeyUrlpins the table forvalkey.url,runs.index_urland--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,--portand-p.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.DEVOPS_CLI_VALKEY_TIMEOUTnamesDEFAULT_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.
dan-petty commentedon Oct 28, 2026
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:
valkey://orvalkeys://URL names every Valkey endpoint: fix(valkey): valkey.url keeps its scheme, so a valkeys url dials tls with host name checks #2026 (merged in fix(valkey): valkey.url keeps its scheme, so a valkeys url dials tls with host name checks #2064) and fix(valkey): valkey.url is one validated url, its path names the database, and the separate host, port and db settings go #2060 (merged in fix(valkey): valkey.url is one validated url, its path names the database, and the separate host, port and db settings go #2087). An offline probe onmainat4226904econfirmed the result; see the premise-check comment above.devops k8s configure-urlssavesvalkey.urlas avalkey://URL: fix(k8s): configure-urls saves valkey.url as a valkey:// URL built with httpx2.URL, and keeps a saved non-loopback URL #1990, closed.No work is left here that #1992 or #1993 does not hold. The sub-issue links stay for the history.