Repository navigation
Closed
Labels
priority/p2-mediumPriority P2: standard workscope/ciGitHub Actions workflows, pre-commit hooks, CI gates, and runnersscope/cliCore CLI framework, Typer subcommands, options, and tablestype/testType test: a new or changed test
Milestone
Description
Problem
Today's floor (tests/conftest.py, 917 lines, 17 autouse fixtures) isolates the data directory, config, kubeconfig, gh config and session bus, and it blocks external network. It does not deny processes, the keyring, loopback services or the Docker socket, and it resets only some state. Instrumented full runs of a copy of 36cfbbb, with a plugin that recorded the edges each test reached, give these figures [measured: 2026-10-07; counts move by a few between runs, because a background export is charged to whichever test is running]:
- Every test exports telemetry. The per-test config turns on export to
localhost:4318[code: tests/conftest.py:465, :471], and about 1,800 tests in about 280 files had that connect refused. - About 470 tests in about 120 files reach another edge with no fake:
- Keyring: about 240 tests in 67 files call the keyring library, and none installs a backend. keyring registers every
KeyringBackendsubclass it has imported, and with the session bus removed it picks the test helperFakeKeyring[code: tests/cluster_secret_fakes.py:37-40] (priority 1) as the process backend. Each worker therefore shares one in-memory keyring, and what one test writes, a later test in that worker reads. The first call in each worker also loads keyring's backends, which startldconfig,gccandld. - Processes: 59 tests in 18 files start a process other than git or bwrap. Most of them run Python children or
kubectl kustomize[code: tests/test_k8s_argocd_apps.py:229, :284, :366]; fix(k8s): argo cd takes homelab values from deploy-time overrides, and the repository holds no private or placeholder config #1290 has since added morekubectl kustomizeruns [code: tests/test_k8s_argocd_apps.py:423; tests/test_k8s_argocd_overrides.py:165, :224; tests/test_k8s.py:1692]. Some run real tools that no fake answers:gh[code: tests/test_github_metrics.py:256],sudo[code: tests/test_devcontainer.py:939],code[code: tests/test_repos.py:960], and Bandit and Semgrep in two tests intest_gateway_review_stall.py. - Loopback: about 95 tests in 31 files connect to a loopback port that no test owns, 70 of them to Valkey's 6379. The guard answers
ECONNREFUSED, so these tests quietly take the offline path. - DNS: about 180 tests in 56 files look up a name that is not loopback with no DNS fake installed, mostly example.com; about 75 of them, in 30 files, look up real names such as radar.cloudflare.com and api.github.com. The guard answers with a lookup failure, so these tests also take the offline path.
- Docker: 8 tests in
test_sandbox_lifecycle.pyandtest_ui_dashboard.pyreach the real engine at/var/run/docker.sock, because the guard passes any address that is not a (host, port) pair [code: tests/conftest.py:88-89].
- Keyring: about 240 tests in 67 files call the keyring library, and none installs a backend. keyring registers every
- Process-wide state outlives its test. 49 src modules hold it [measured: AST scan at 36cfbbb]: 29 names rebound through
global, 20 module-level containers that functions mutate, 40functools.cache/lru_cachesites and 4 class-level singletons.- The floor resets settings, the tracer, the console, the dry-run state, the GitHub session, the Docker engine and the LLM response cache.
- It calls none of 14 other resets that exist, for example those of KubernetesService [code: k8s/service.py:83], the shared HTTP clients [code: http/pool.py:104] and the GitHub rate limiter [code: github/rate_limiter.py:1344]. It pins the GitHub token by setting a private name [code: tests/conftest.py:357] instead of calling
reset_github_token[code: core/process.py:296]. - 9 states have no reset at all, for example the spend ledger [code: ai/spend/ledger.py:558] and the default HTTP broker, which is built from the environment at import [code: http/broker.py:186]. Neither has the console: conftest assigns its private names directly [code: tests/conftest.py:268-269].
- Fixture and helper defects.
guard_live_rag_data[code: tests/conftest.py:479-520] reads the developer's config before any test's config is isolated (:493). It guards only URLs that contain that config'sk8s.domain, and it rebindsQdrantClient.__init__for the rest of the run.verify_test_paths_isolated[code: :537-550] cannot fail, because it checks thetmp_pathvalues the other fixtures set. Its constant,CONST_ISOLATED_TEST_ENV_KEYS[code: config/constants.py:444], has no other reader.tmp_ssh_dir,tmp_repos_dirandmock_settings[code: tests/conftest.py:695-706, :718-729] have no users;test_cloudflare_commands.pydefines its ownmock_settings[code: tests/test_cloudflare_commands.py:27-28].forbid_requests[code: tests/cluster_secret_fakes.py:221], called 9 times in three files to refuse every process, keyring call and socket, does by hand what a default deny does for every test, and it patches the tracer's private_resolve_telemetry_settingsto do it [code: tests/cluster_secret_fakes.py:231].
- There is no shared CLI or config fixture. 130 test files build a module-level
runner = CliRunner()[measured: AST at 5c45b1e], and tests replace settings by patchingload_settings(135 sites in 38 files [measured: census at 36cfbbb]).
Acceptance criteria
Default deny
- A test that reaches a faked edge with no fake installed fails with an error that names the edge and the target, such as
process edge reached without a fake: gh api user. The floor records every reach and fails the test again at teardown, so a test still fails when the code under test catches the error. The deny covers three edges:- processes: any process other than git and bwrap, denied at
subprocess.Popen, which also covers the async runner and the 11 direct spawners; - network: any connect outside loopback, a loopback port or AF_UNIX path that no listener in the test owns, and any DNS lookup of a name that is not loopback;
- keyring: any read or write, refused by a deny backend that the floor installs with
keyring.set_keyringbefore the first test, so keyring's backend discovery never runs and never selects a test helper such asFakeKeyring.
- processes: any process other than git and bwrap, denied at
- A connect to a port or socket the test itself listens on still passes, so in-process servers stay real.
- A test that runs a real local tool declares it, and it is skipped where the tool is missing. git and bwrap need no declaration.
- Every test that reaches an edge today passes under the deny. Each one does one of three things: installs a fake through an existing seam or fixture (
docker_engine,stub_web,public_dns,roadmap_store, a keyring fake); declares the state it depends on; or becomes a live test. None adds an internal patch or a private import (test(cli): ratchets hold internal patches, private imports and test accommodations in src at today's counts and name each site that would raise one #1309). The realgh,sudo,code, Bandit, Semgrep and Docker-engine reaches are gone. -
forbid_requestsis deleted. Its 9 calls intests/test_k8s.py,tests/test_k8s_push_secrets.pyandtests/test_k8s_run_job.pyrely on the deny instead, which also fails a test whose code caught the refusal. -
pytestertests cover each edge. A test without a fake fails with the edge's name, including a test whose code catches the error. An in-process server passes. These tests live intests/invariants/test_hermetic_floor.py, the subject file for the floor, which this PR creates; test(cli): Convert ratchets to bans and merge invariant tests #1336 later mergestest_isolation_tripwire.pyinto it.
Telemetry and state
- The floor's config turns telemetry export off, and a test opts in through
config. No test connects tolocalhost:4318unless it opted in. - After each test, the floor calls the public reset of every piece of process-wide state in src and closes the shared HTTP clients. Where a public reset is missing, this PR adds one, the console's included.
- An invariant test fails, naming
path:line, on module-level state in src that the floor does not reset. It checks four forms: a name rebound throughglobal, a module-level container a function mutates, afunctools.cache/lru_cachefunction, and a class attribute a classmethod rebinds. It joins the source-tree invariants:tests/invariants/test_source_tree.pyif test(cli): ratchets hold internal patches, private imports and test accommodations in src at today's counts and name each site that would raise one #1309 has created it, otherwisetests/test_architectural_invariants.py.
Fixtures
-
config, in the root conftest, writes overrides into the per-testconfig.yamlthatDEVOPS_CLI_CONFIGnames, then resets the settings cache. Its tests showload_settings()reading an override, and two tests that do not see each other's overrides. None of them patchesload_settings,CONFIG_PATHorget_settings. -
cli, in the root conftest, runsdevops <args>in process throughdevops_cli.main.app[code: main.py:80] with the floor's terminal settings. It takesinput=for stdin and returns the result. - These are deleted:
guard_live_rag_data, whose job the network deny now does for every Qdrant URL;verify_test_paths_isolated, with_check_test_paths_isolatedand its tripwire test;CONST_ISOLATED_TEST_ENV_KEYS;tmp_ssh_dir;tmp_repos_dir; conftest'smock_settings. - Summed setup and teardown time from
--durations(137.4 s and 20.4 s on 2026-10-07) grows by at most 10%. - If test(cli): ratchets hold internal patches, private imports and test accommodations in src at today's counts and name each site that would raise one #1309 has landed, its ceilings drop by the patches this PR removes (the console assignments,
guard_live_rag_data's rebinding ofQdrantClient.__init__andforbid_requests' tracer patch among them). -
changelog.d/<n>.mdrecords the change;CHANGELOG.mdanddocs/ROADMAP.mdare not edited. -
uv run devops cipasses.
Key questions
- What does the floor deny, and what stays real? Decided 2026-10-07: every faked edge is denied, and a test that reaches one without a fake fails with an error naming the edge. git in temporary repositories, bwrap in marked live tests, in-process servers, files under
tmp_path, and env and config stay real. - State, telemetry and fixtures? Decided 2026-10-07: every process-wide reset runs after each test, and an invariant guards that; telemetry export is off unless a test opts in with the OTLP fake; there is a
configfixture and one sharedclifixture in the root conftest. (proposed) Until refactor(telemetry): OTLP export goes through one exporter seam, and tests read exported spans and metrics from a shared fake #1319 lands the OTLP fake, an opted-in test keeps its current sink. - What stays in the root conftest? Decided 2026-10-07: only the floor. Domain fixtures move to package conftests or next to their fake, and the session guard that reads the real config,
guard_live_rag_data, gets fixed. (proposed) It is deleted here, because the deny refuses every Qdrant connect that has no fake. The domain fixtures move in test(cli): every test file sits in the directory mirroring the package it tests or in tests/invariants/, and the root conftest holds only the hermetic floor #1313's split, which also movescliandconfigtotests/support/, still registered from the root conftest. - Are the module-level runners and the
load_settingspatches converted here? (proposed) No. Each package item converts its own files. - How does a test declare an unreachable service, or a live tool, before its edge has a fake? (proposed) With two markers:
unreachable("localhost:6379")refuses the endpoint without failing the test. It is interim. refactor(cli): Unify HTTP and DNS seams with shared fakes #1314–refactor(telemetry): OTLP export goes through one exporter seam, and tests read exported spans and metrics from a shared fake #1319 each delete the markers for their edge when their fake lands. Where the edge's seam is an existing issue (refactor(cli): one process runner owns execution, process groups and dry-run #775, refactor(github): the github session owns transport, ledger, error classes and link pagination #983, refactor(ai): one model seam: llmclient over three wire adapters behind one factory, no second provider stack #1001), and where the code under test bypasses a refactor(cli): Unify HTTP and DNS seams with shared fakes #1314–refactor(telemetry): OTLP export goes through one exporter seam, and tests read exported spans and metrics from a shared fake #1319 seam, the E item whose file list names the test file deletes the markers, since each E item lands after the seams its package uses. test(cli): Convert ratchets to bans and merge invariant tests #1336 bans the marker;live("kubectl")allows the binary and skips the test where the binary is missing. It is how a live test is marked, and it stays.
- Why delete
forbid_requestshere? (proposed) The deny refuses everything it refuses, and the floor's telemetry-off default replaces its private tracer patch, so keeping it would leave a second, weaker deny for later items to remove. The dry-run tests that refuse processes or sockets inline [code: tests/test_roadmap_dry_runs.py:78-80, :292-295] keep those lines, which are stdlib patches the deny makes redundant but not wrong; their refusals of devops-cli internals go with their package items. - What is the keyring before refactor(security): one keyring seam owns the keyring and the Secret Service lock check, with a shared keyring fake and its contract suite #1318? (proposed) The deny backend. A test that needs a keyring installs a fresh
FakeKeyringfromtests/cluster_secret_fakes.pywithkeyring.set_keyring, and the floor puts the deny backend back after it. - What about a reach from a thread that a finished test started? (proposed) Teardown stops what the test started (tracer shutdown, pool close). A reach outside any test fails the session.
- Does the telemetry-off default fix fix(ci): review workflow tests start the logfire SDK's credential check, which the network guard blocks #965? (proposed) Maybe, but this item does not claim it. The PR runs fix(ci): review workflow tests start the logfire SDK's credential check, which the network guard blocks #965's reproduction and reports the result.
- Is this one pull request? (proposed) Yes, because the per-test changes are mechanical. Refinement splits it by edge if review finds it too large.
Strategic alignment
- Milestone: none; the roadmap tooling places it. Depends on: none. Blocks: test(cli): every test file sits in the directory mirroring the package it tests or in tests/invariants/, and the root conftest holds only the hermetic floor #1313. Related: fix(ci): tests touch no state outside their temporary directories #1311 (also edits the root conftest), test(cli): ratchets hold internal patches, private imports and test accommodations in src at today's counts and name each site that would raise one #1309 (counts the floor's remaining patches), fix(ci): the live bubblewrap tests run wherever bwrap is installed and skip only where it is missing #1337 (the bwrap skip in the same collection hook), fix(ci): review workflow tests start the logfire SDK's credential check, which the network guard blocks #965 (Logfire credential check), fix(test): tests never write to the project config, data or tracked files #749 and fix(test): the test network guard refuses loopback connects to services the test did not start #837 (tripwire, loopback refusal), refactor(cli): Unify HTTP and DNS seams with shared fakes #1314–refactor(telemetry): OTLP export goes through one exporter seam, and tests read exported spans and metrics from a shared fake #1319 (fakes that replace the interim
unreachablemarkers), refactor(cli): one process runner owns execution, process groups and dry-run #775, refactor(github): the github session owns transport, ledger, error classes and link pagination #983 and refactor(ai): one model seam: llmclient over three wire adapters behind one factory, no second provider stack #1001 (fakes after which the E items delete the markers for those edges), test(cli): Convert ratchets to bans and merge invariant tests #1336 (bans the marker). - Parent: test(cli): tests double only process edges and mirror the source tree #1307 (phase B).
Metadata
Metadata
Assignees
Labels
priority/p2-mediumPriority P2: standard workscope/ciGitHub Actions workflows, pre-commit hooks, CI gates, and runnersscope/cliCore CLI framework, Typer subcommands, options, and tablestype/testType test: a new or changed test
Type
Projects
- StatusShow more project fieldsDone
Activity
dan-petty commentedon Oct 8, 2026
Linked: #1113. #1113 replaces the hand-written Valkey client (
valkey/client.py,valkey/protocol.py) andcache/with GLIDE behind one store; this item's Valkey work targets code #1113 deletes, so whichever lands second moves it onto #1113's store. Found by the 2026-10-08 backlog review.dan-petty-bot commentedon Oct 8, 2026
Intake placed this item to the backlog: at intake only a critical fix goes into a release; a release start pulls Ready items in, P0 features first.
Test isolation gaps make the suite unreliable and can cause flaky or order-dependent failures, but no production code or security boundary is directly broken.Without a correct hermetic floor, ~1,800 tests silently take offline paths, ~470 reach un-faked edges, and 49 modules leak state, undermining the entire test suite's trustworthiness.Fixing requires adding fakes for keyring, processes, loopback, DNS and Docker, wiring 14+ missing state resets, and correcting fixture ordering defects across a 917-line conftest with 17 autouse fixtures.dan-petty commentedon Oct 20, 2026
Amendment from #1725's kubectl decision (2026-10-20, in the comment on #1725).
This item's process deny lets only git and bwrap through, and uses a
live("kubectl")marker for tests that need kubectl. That now contradicts #1725.All 33 tests that start
kubectlrun its offline renderers:kubectl kustomize, plus onekubectl patch --local. Most of them check the committedk8s/manifests or kubectl's own behaviour, and none reaches a cluster. There is no maintained kustomize in Python, and a recorded render would check the recording rather than the repository. So these renderers are allowed in tests, like git.Change to this item: the process deny admits
kubectl kustomizeandkubectl patch --localas well as git and bwrap, and refuses every other kubectl subcommand. The incidentalkubectl config get-contextsfrom devcontainer post-start is already gone (perf/1725-devcontainer-tests).test(cli): enforce hermetic floor edge denial and process-wide state …
dan-petty commentedon Oct 21, 2026
What changed
#1776, merged into
release/v0.2.38as e66ce73.151 file(s) changed.
How it was verified
Check runs at dabd55d:
Acceptance Criteria of
docs/agent/tasks/task-1310-hermetic-floor.md:No Acceptance Criteria section.
feat(release): v0.2.38 (#1799)
feat(release): v0.2.38 (#1798)