Repository navigation
Closed
Labels
priority/p0-criticalPriority P0: a release blocker or a critical defectscope/cliCore CLI framework, Typer subcommands, options, and tablestype/bugType bug: the code does not do what it must
Milestone
Description
Context & Rationale
prevent_external_network_calls (tests/conftest.py:56-120) claims to 'Guarantee that tests never hit external APIs or endpoints'. AGENTS.md:381 forbids live endpoints in test suites.
What the guard actually does:
- It blocks DNS lookups and connects to hosts that are not loopback.
_is_loopback(:65-71) lets every loopbackconnectandconnect_exthrough (:95-115).- The isolated test config turns telemetry on at
http://localhost:4318(:231,:236).
On a workstation that holds kubectl port-forwards, a loopback connect reaches the cluster.
ROADMAP.md:1046 (P0, no issue) measured this with a probe plugin that refused loopback connects to ports without an in-process listen():
- 5,217 refused connects to the OTLP collector;
- 26 to Valkey;
- 21 to Ollama;
- the suite still passed 5,732 tests.
CI declares no services:, so it only runs the connection-refused branches, while a workstation runs the live ones. The only per-client escape hatch is the pytest check at ai/rag/embeddings.py:264, together with DEVOPS_CLI_TEST_LIVE_VALKEY (tests/test_rag_embeddings.py:584, :603).
Scope & Deliverables
- Deliverable (the design in
ROADMAP.md:1046):- The session guard wraps
socket.socket.listenand records the ports the test process owns. - A loopback
connectto any other port raisesConnectionRefusedError(ECONNREFUSED), andconnect_exreturnsECONNREFUSED. - Non-loopback connects keep raising the
RuntimeError. - Delete the check at
embeddings.py:264andDEVOPS_CLI_TEST_LIVE_VALKEY, and rewrite the two tests that set it. - Optional: list the refused loopback attempts by port in the terminal summary.
- The session guard wraps
- Acceptance criteria:
- A connect to a loopback port that nothing in-process listens on raises
ConnectionRefusedError, andconnect_exreturnsECONNREFUSED. - A test that starts its own server in-process can still connect to it.
- The full suite passes both with the usual port-forwards running and with none.
- The task file records the
devops citest-step duration on ext4 before and after the change, with the usual port-forwards running. rg DEVOPS_CLI_TEST_LIVE_VALKEY src testsreturns nothing.
- A connect to a loopback port that nothing in-process listens on raises
- Key questions:
- Would
pytest-socketbe simpler? (proposed) No.ROADMAP.md:1046found that its--allow-hoststakes hosts rather than ports, and its errors subclassRuntimeError.
- Would
- Constraint:
- The denial must look like a refused connection.
ValkeyClientmaps onlyOSError(valkey/client.py:168-174), andValkeyCache.is_availablecatches onlyValkeyError(ai/cache/valkey_cache.py:58-61), so aRuntimeErrorwould escape both. - Subprocesses spawned by tests are not covered by an in-process guard. Say so in the guard's docstring.
- One PR, and the task file marks
ROADMAP.md:1046delivered.
- The denial must look like a refused connection.
Strategic Alignment
- Milestone: v0.2.24 if admitted as a critical fix; otherwise Backlog, ranked first.
- Design: CONTEXT.md (Critical fix)
- Depends on: none
Metadata
Metadata
Assignees
Labels
priority/p0-criticalPriority P0: a release blocker or a critical defectscope/cliCore CLI framework, Typer subcommands, options, and tablestype/bugType bug: the code does not do what it must
Type
Projects
- StatusShow more project fieldsDone
Activity
dan-petty commentedon Oct 1, 2026
Admitted to v0.2.24 as a critical fix, by the owner's decision (2026-10-01): a P0 defect fix. Every test run reaches live loopback services, and the guard's own docstring says it shouldn't.
fix(test): the network guard refuses loopback connects to services th…
dan-petty commentedon Oct 1, 2026
Closed by #866, merged into
release/v0.2.24.GitHub only acts on closing keywords when a pull request merges into the default branch, so this was closed by
devops gh issues close-merged.feat(release): v0.2.24 (#905)