Repository navigation
Description
Problem
Counts come from one AST pass over tests/test_*.py at 5c45b1e, the head of release/v0.2.28, and [code: …] lines are at the same commit. A file belongs to the package it references most, as in the census.
- Files. 14 test files have
commands/k8s/as their primary package: 5,585 lines, 238 tests [measured: AST pass at 5c45b1e].- They are
test_k8s,test_k8s_bootstrap,test_k8s_context,test_k8s_devops_stack,test_k8s_jaeger,test_k8s_logging_stack,test_k8s_networking,test_k8s_proxy_addressing,test_k8s_qdrant_security,test_k8s_rbac_audit,test_k8s_run_job,test_k8s_runtime_cmd,test_k8s_tlsandtest_subsystem_containment_and_redaction. - Three more,
test_k8s_llm_gateway,test_k8s_monitoring_integrationandtest_k8s_network_policies, check committed manifests and go totests/invariants/.
- They are
- Coupling. These files hold 265 patch sites aimed at devops_cli internals [measured]. 8 of them name their target through the
_RUN_CMDstring constant [code: tests/test_k8s_rbac_audit.py:16].- 136 of the string-target patches replace the process layer:
_run_cmd,_cluster_reachable,_minikube_runningandrun_subprocess. Tests reach them asdevops_cli.commands.k8s.Xor...stack_lifecycle.runtime._run_cmd. - The files also make 76 private imports, in 9 files, and 8 of the 14 build a module-level
runner = CliRunner(). - Those three and
test_k8s_argocd_appsadd 7 private imports ofcommands/k8stables and helpers [code: tests/test_k8s_llm_gateway.py:12; tests/test_k8s_monitoring_integration.py:12-13; tests/test_k8s_network_policies.py:11, :229; tests/test_k8s_argocd_apps.py:12].
- 136 of the string-target patches replace the process layer:
- Product code shaped for patching (Q27).
commands/k8s/__init__.pyswaps its own module class for_K8sModule[code: commands/k8s/init.py:245, :253].- That class's
__setattr__forwards a patched name into four submodules. It does so through_forward_submodule_attr[code: commands/k8s/init.py:229],_PATCH_TARGET_MAP[code: commands/k8s/init.py:223] and three name sets [code: commands/k8s/init.py:194-222]. - 22 of the 57 names in its
__all__are private [code: commands/k8s/init.py:134-192].
- Edges outside a seam.
- kubectl wrappers live in each module [code: commands/k8s/cluster_runtime.py:38
_run_cmd; commands/k8s/cluster_jobs.py:82_kubectl]. shutil.whichis called directly [code: commands/k8s/cluster_runtime.py:91].- The port-forward daemon starts with
subprocess.Popen[code: commands/k8s/networking.py:1005]. - Kubernetes clients are loaded beside
KubernetesService[code: commands/k8s/cluster_runtime.py:29; commands/k8s/cluster_context.py:128]. time.sleepis called directly [code: commands/k8s/cluster_jobs.py:117, :137; commands/k8s/networking.py:1112].stack_lifecycle.pywrites the keyring through the privateconfig.settings._keyring_set[code: commands/k8s/stack_lifecycle.py:456].- URL reachability is a raw TCP connect [code: commands/k8s/networking.py:226].
- kubectl wrappers live in each module [code: commands/k8s/cluster_runtime.py:38
- Logic living in commands/ (Q19).
- The stack catalogue:
_HELM_REPOS_BY_STACK,_HELM_RELEASES_BY_STACKand_MANIFESTS_BY_STACK[code: commands/k8s/stack_lifecycle.py:54, :78, :168]. - URL resolution:
_parse_minikube_service_url,_extract_first_node_ip,_resolve_k8s_node_port_urland_resolve_accessible_url[code: commands/k8s/networking.py:76, :85, :103, :339]. _PROXY_TARGETS_INFRA[code: commands/k8s/networking.py:491] and_get_openwebui_bootstrap_credentials[code: commands/k8s/stack_lifecycle.py:297].- The Argo CD host overrides that fix(k8s): argo cd takes homelab values from deploy-time overrides, and the repository holds no private or placeholder config #1290 added:
_homelab_applications,_homelab_host_overridesand_set_homelab_hosts[code: commands/k8s/stack_lifecycle.py:766, :806, :855], beside the domain modulek8s/argocd_overrides.py. networking.pyis 1,229 lines andstack_lifecycle.pyis 1,231.
- The stack catalogue:
- Files and names.
test_k8s.py(2,051 lines, 67 tests) covers deploy, bootstrap, teardown, URL configuration, contexts, the logs-and-metrics stack (:1298) and, since fix(k8s): argo cd takes homelab values from deploy-time overrides, and the repository holds no private or placeholder config #1290, deployment onto an Argo CD cluster (:1631-:2051). Several of its tests take committed manifests or values files as their subject rather than run code (for example:1126,:1320,:1380,:1499).- The fix(k8s): argo cd takes homelab values from deploy-time overrides, and the repository holds no private or placeholder config #1290 tests answer kubectl with
_Cluster, a hand-rolled recorder that runs git andkubectl kustomizefor real [code: tests/test_k8s.py:1657]. They install it by patchingcluster_runtime._run_cmd[code: tests/test_k8s.py:1726, :1943] and write the service config through their own_configure_service[code: tests/test_k8s.py:1715-1721]. - Two more process doubles are patched onto
core.process.subprocess.run:FakeClusterfromtests/cluster_secret_fakes.py[code: tests/test_k8s_qdrant_security.py:157-159] andFakeJobs[code: tests/test_k8s_run_job.py:34, :67-69]. Two of these files also useforbid_requestsfrom the same helper module [code: tests/test_k8s.py:184, :215; tests/test_k8s_run_job.py:22]. - Catch-alls:
test_k8s.py:755,:848,:916andtest_k8s_networking.py:35. test_subsystem_containment_and_redaction.pytests four packages through private names (:31,:35,:214,:248).
Acceptance criteria
- No internal patches or private imports.
- The test files under
tests/commands/k8s/have zero patch sites aimed at devops_cli internals and zero private imports. - The four manifest invariant tests (the three above and
test_k8s_argocd_apps) import public names. - 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 two ceilings drop by the counts these files carry when the item starts (265 and 83 at 5c45b1e).
- The test files under
- Patch forwarding is gone.
_K8sModule,_forward_submodule_attr,_PATCH_TARGET_MAPand the three name sets are deleted.commands/k8s/__init__.pyexports no private name.rg -n "_K8sModule|_PATCH_TARGET_MAP|__class__ =" src/devops_cli/commands/k8sprints nothing.
- Processes run through refactor(cli): one process runner owns execution, process groups and dry-run #775.
- kubectl, helm, minikube and the port-forward daemon all run through the process runner; the per-module kubectl wrappers (
_run_cmd,_kubectl) go. - Tests script them by argv on the process fake, which also answers
shutil.which. _Cluster,FakeClusterandFakeJobsgive way to the process fake. git stays real (Q23), and a test that renders withkubectl kustomizedeclares it as a real local tool, as test(cli): the hermetic floor fails a test that reaches an edge without a fake and resets all process-wide state after every test #1310 requires.forbid_requestsgives way to test(cli): the hermetic floor fails a test that reaches an edge without a fake and resets all process-wide state after every test #1310's default deny.- Whichever of this item and test(k8s): k8s/ is tested through its public interface over the Kubernetes API, process, HTTP and keyring fakes, with no internal patches or private imports #1322 lands second deletes
tests/cluster_secret_fakes.py. By then test(cli): the hermetic floor fails a test that reaches an edge without a fake and resets all process-wide state after every test #1310 has deletedforbid_requests, refactor(security): one keyring seam owns the keyring and the Secret Service lock check, with a shared keyring fake and its contract suite #1318 has movedFakeKeyringtotests/support/fakes/keyring.py, and no test imports from the module. - No test patches
_run_cmd,_cluster_reachable,_minikube_running,run_subprocessorsubprocess.run.
- kubectl, helm, minikube and the port-forward daemon all run through the process runner; the per-module kubectl wrappers (
- Other edges through their seams.
- Kubernetes clients come only from refactor(k8s): KubernetesService is the Kubernetes API seam, with a shared fake cluster and its contract suite #1315's seam.
cluster_runtime.py:29andcluster_context.py:128load none of their own. - Keyring reads and writes go through refactor(security): one keyring seam owns the keyring and the Secret Service lock check, with a shared keyring fake and its contract suite #1318;
stack_lifecycle.pyno longer imports_keyring_set. - Reachability probes connect to loopback listeners the test starts (Q23).
- Waits go through refactor(cli): tests control time: time-machine fakes wall-clock reads, and retry and rate-limit waits return at once and are recorded #1320.
- Settings go through test(cli): the hermetic floor fails a test that reaches an edge without a fake and resets all process-wide state after every test #1310's
configfixture, which replaces_configure_service.
- Kubernetes clients come only from refactor(k8s): KubernetesService is the Kubernetes API seam, with a shared fake cluster and its contract suite #1315's seam.
- No interim markers. If test(cli): the hermetic floor fails a test that reaches an edge without a fake and resets all process-wide state after every test #1310 added its interim
unreachable(...)marker, none remains in this item's test files: each gives way to the fake of the edge it names, in the fake's refusing state where the test relies on the refusal. - Logic out of commands/ (Q19).
- The stack catalogue, URL resolution and proxy targets move into
k8s/under public names, and the host-override derivation joinsk8s/argocd_overrides.py. Each is tested intests/k8s/. - The
commands/k8smodules become thin adapters. - CLI tests use the shared
clifixture in place of the 8 module-level runners, and check only parsing, wiring, output and exit codes (Q14).
- The stack catalogue, URL resolution and proxy targets move into
- The cross-package test file dissolves.
test_subsystem_containment_and_redaction.pyis deleted. Each of its behaviours is tested through the public interface of the package that owns it (Q13). - Behaviour files and names.
test_k8s.pyis deleted. Its tests move to behaviour files such astest_stack_deploy.py,test_argocd_deploy.py,test_cluster_bootstrap.pyandtest_stack_teardown.py.- No test under
tests/commands/k8s/reads a file under the repository'sk8s/directory. Those tests are added to the Q13 subject filetests/invariants/test_k8s_manifests.py, which this item creates if no earlier item has; no second manifest file is added beside it, and test(cli): Convert ratchets to bans and merge invariant tests #1336 merges the manifest files 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 moved into it. - The catch-alls listed above are dissolved.
- Test names state behaviour (Q8), and assertions compare whole values (Q7).
- Snapshots. Dry-run previews [code: commands/k8s/networking.py:805] and command output are compared as syrupy snapshots (Q18; test(cli): tests find the repository root and fixtures from any depth, import no other test module and build test data with shared builders, and devops test maps a change to its mirror directory #1312 adds syrupy).
- Dead code. Every line that no public behaviour reaches is deleted (Q22). The 90% coverage gate passes.
-
changelog.d/<n>.mdrecords the change;CHANGELOG.mdanddocs/ROADMAP.mdare not edited. -
uv run devops cipasses.
Key questions
- Which files belong to this item? Decided 2026-10-07: under Q17, each file goes to the package that owns most of what it tests, and 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 places it in that package's mirror directory. This item owns exactly the files named above;
tests/commands/is shared, and each file in it belongs to the one E item that names it. - Where do the stack tables go? (proposed) Into a public module in
k8s/(for examplek8s/stacks.py). The manifest invariant tests and the commands then read the same public names. - Is this one pull request? Decided 2026-10-07: under Q33, it is filed now as one item. Refinement applies
needs-splitif it proves too big.
Strategic alignment
- Milestone: none; the roadmap tooling places it. Depends on: 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, refactor(cli): one process runner owns execution, process groups and dry-run #775, refactor(k8s): KubernetesService is the Kubernetes API seam, with a shared fake cluster and its contract suite #1315, refactor(security): one keyring seam owns the keyring and the Secret Service lock check, with a shared keyring fake and its contract suite #1318, refactor(cli): tests control time: time-machine fakes wall-clock reads, and retry and rate-limit waits return at once and are recorded #1320. Blocks: test(cli): Convert ratchets to bans and merge invariant tests #1336. Related: 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 ratchets this item lowers), test(k8s): k8s/ is tested through its public interface over the Kubernetes API, process, HTTP and keyring fakes, with no internal patches or private imports #1322 (owns
k8s/andk8s/argocd_overrides.py; adds thedevops k8s podsCLI tests undertests/commands/k8s/), test(cli): the infra commands are thin adapters tested over edge fakes, with no internal patches or private imports #1327 (ownscommands/vault.py, whose path check is tested here today), fix(k8s): argo cd takes homelab values from deploy-time overrides, and the repository holds no private or placeholder config #1290 (added the Argo CD deploy path and its tests), feat(cli): reachable--dry-runpreviews for delegated commands #412 (reachable--dry-runpreviews). - Parent: test(cli): tests double only process edges and mirror the source tree #1307 (phase E).
Update 2026-10-08: refinement
_KUSTOMIZATIONS_BY_STACK (commands/k8s/stack_lifecycle.py:201) moves too, and stack names live in three places (commands/k8s/networking.py:60, :63-67; stack_lifecycle.py:205).
- The names are defined once in
k8s/. - The argv builder passes the context from
resolve_context(k8s/context.py:78) when one resolves;resolve_effective_contextgoes; a test coverscluster_context.py:203andsecurity_audit.py:44.
Proposed design
Problem statement
The k8s devops command modules in commands/k8s/ hold business logic (stack catalogue, URL resolution, proxy targets, host overrides) and are shaped so that tests can patch their internals. Their 14 test files (5,585 lines, 238 tests) use 242 patch sites and 94 private imports to reach devops_cli internals. The _K8sModule class in commands/k8s/__init__.py forwards patched names into submodules, making the module a test-patching target. Process calls (kubectl, helm, minikube, port-forward) bypass the #775 process runner seam. This item makes commands/k8s/ thin adapters, moves logic into k8s/ domain modules, routes all edges through their seams, and rewrites the tests to use only public interfaces and process fakes.
Acceptance criteria
- Criterion 1: The test files under
tests/commands/k8s/have zero patch sites aimed at devops_cli internals and zero private imports.
Verification: Runrg -n 'patch\(|mock\.|_run_cmd|_cluster_reachable|_minikube_running|run_subprocess' tests/commands/k8s/and confirm no output. Runrg -n 'from devops_cli\..*_\w+ import|from devops_cli\.\w+\.\w+ import _\w+' tests/commands/k8s/and confirm no output. - Criterion 2:
_K8sModule,_forward_submodule_attr,_PATCH_TARGET_MAPand the three name sets are deleted fromcommands/k8s/__init__.py.
Verification: Runrg -n '_K8sModule|_PATCH_TARGET_MAP|__class__ =|_forward_submodule_attr' src/devops_cli/commands/k8sand confirm no output. - Criterion 3:
commands/k8s/__init__.pyexports no private name in its__all__.
Verification: Runpython -c "import devops_cli.commands.k8s as m; privs=[n for n in m.__all__ if n.startswith('_')]; assert not privs, privs"and confirm it exits 0. - Criterion 4: kubectl, helm, minikube and the port-forward daemon all run through the refactor(cli): one process runner owns execution, process groups and dry-run #775 process runner; the per-module wrappers
_run_cmdand_kubectlare deleted.
Verification: Runrg -n 'def _run_cmd|def _kubectl' src/devops_cli/commands/k8s/and confirm no output. Runrg -n 'subprocess\.run|subprocess\.Popen' src/devops_cli/commands/k8s/and confirm no output outside the process runner seam. - Criterion 5: Kubernetes clients come only from refactor(k8s): KubernetesService is the Kubernetes API seam, with a shared fake cluster and its contract suite #1315's seam;
cluster_runtime.pyandcluster_context.pyload none of their own.
Verification: Runrg -n 'kubernetes\.|KubernetesService|ApiClient' src/devops_cli/commands/k8s/cluster_runtime.py src/devops_cli/commands/k8s/cluster_context.pyand confirm no direct client construction. - Criterion 6: Keyring reads and writes go through refactor(security): one keyring seam owns the keyring and the Secret Service lock check, with a shared keyring fake and its contract suite #1318;
stack_lifecycle.pyno longer imports_keyring_set.
Verification: Runrg -n '_keyring_set' src/devops_cli/commands/k8s/stack_lifecycle.pyand confirm no output. - Criterion 7: The stack catalogue (
_HELM_REPOS_BY_STACK,_HELM_RELEASES_BY_STACK,_MANIFESTS_BY_STACK,_KUSTOMIZATIONS_BY_STACK) and URL resolution functions move into a public module ink8s/.
Verification: Runrg -n '_HELM_REPOS_BY_STACK|_HELM_RELEASES_BY_STACK|_MANIFESTS_BY_STACK|_KUSTOMIZATIONS_BY_STACK|_parse_minikube_service_url|_extract_first_node_ip|_resolve_k8s_node_port_url|_resolve_accessible_url' src/devops_cli/commands/k8s/and confirm no output. Confirm the names exist insrc/devops_cli/k8s/under public names. - Criterion 8: Stack names are defined once in
k8s/and not duplicated acrossnetworking.pyandstack_lifecycle.py.
Verification: Runrg -n 'STACK_NAMES|_STACKS' src/devops_cli/commands/k8s/networking.py src/devops_cli/commands/k8s/stack_lifecycle.pyand confirm the names are imported fromk8s/rather than redefined. - Criterion 9: The Argo CD host-override derivation (
_homelab_applications,_homelab_host_overrides,_set_homelab_hosts) joinsk8s/argocd_overrides.py.
Verification: Runrg -n '_homelab_applications|_homelab_host_overrides|_set_homelab_hosts' src/devops_cli/commands/k8s/stack_lifecycle.pyand confirm no output. Confirm the functions exist insrc/devops_cli/k8s/argocd_overrides.py. - Criterion 10: The single kubectl/helm argv builder resolves the context through
resolve_contextand adds--context(or--kube-contextfor helm).resolve_effective_contextis deleted.
Verification: Runrg -n 'resolve_effective_context' src/devops_cli/and confirm no output. Runrg -n 'resolve_context' src/devops_cli/k8s/and confirm the argv builder calls it. Confirm tests covercluster_context.py:203andsecurity_audit.py:44context passing. - Criterion 11: No test patches
_run_cmd,_cluster_reachable,_minikube_running,run_subprocessorsubprocess.run.
Verification: Runrg -n 'patch.*(_run_cmd|_cluster_reachable|_minikube_running|run_subprocess|subprocess\.run)' tests/and confirm no output. - Criterion 12:
test_k8s.pyis deleted and its tests move to behaviour files such astest_stack_deploy.py,test_argocd_deploy.py,test_cluster_bootstrap.pyandtest_stack_teardown.py.
Verification: Confirmtests/test_k8s.pydoes not exist. Confirm the behaviour files exist undertests/commands/k8s/and their test names state behaviour. - Criterion 13:
test_subsystem_containment_and_redaction.pyis deleted and each of its behaviours is tested through the public interface of the owning package.
Verification: Confirmtests/test_subsystem_containment_and_redaction.pydoes not exist. Confirm the four behaviours are covered in the respective package test files. - Criterion 14: No test under
tests/commands/k8s/reads a file under the repository'sk8s/directory. Those tests are intests/invariants/test_k8s_manifests.py.
Verification: Runrg -n 'Path\("k8s/|k8s/.*\.yaml' tests/commands/k8s/and confirm no output. Confirmtests/invariants/test_k8s_manifests.pyexists and holds the manifest tests. - Criterion 15: Dry-run previews and command output are compared as syrupy snapshots.
Verification: Runrg -n 'snapshot' tests/commands/k8s/and confirm snapshot assertions exist. Confirmsyrupyis in the test dependencies. - Criterion 16: Every line that no public behaviour reaches is deleted. The 90% coverage gate passes.
Verification: Runuv run devops ciand confirm the coverage gate passes at 90% or above. - Criterion 17:
changelog.d/.mdrecords the change.
Verification: Confirm a file matchingchangelog.d/*.mddescribes this change. ConfirmCHANGELOG.mdanddocs/ROADMAP.mdare not edited. - Criterion 18:
uv run devops cipasses.
Verification: Runuv run devops ciand confirm exit code 0. - Criterion 19: The four manifest invariant tests (
test_k8s_llm_gateway,test_k8s_monitoring_integration,test_k8s_network_policies,test_k8s_argocd_apps) import public names only.
Verification: Runrg -n 'from devops_cli\.commands\.k8s\.\w+ import _\w+' tests/test_k8s_llm_gateway.py tests/test_k8s_monitoring_integration.py tests/test_k8s_network_policies.py tests/test_k8s_argocd_apps.pyand confirm no output. - Criterion 20: The catch-all tests at
test_k8s.py:755,:848,:916andtest_k8s_networking.py:35are dissolved into specific behaviour tests.
Verification: Confirm the catch-all test functions no longer exist. Confirm their assertions are covered by named behaviour tests.
Key questions
- Which files belong to this item?: The 14 test files named in the body: test_k8s, test_k8s_bootstrap, test_k8s_context, test_k8s_devops_stack, test_k8s_jaeger, test_k8s_logging_stack, test_k8s_networking, test_k8s_proxy_addressing, test_k8s_qdrant_security, test_k8s_rbac_audit, test_k8s_run_job, test_k8s_runtime_cmd, test_k8s_tls, and test_subsystem_containment_and_redaction. Decided 2026-10-07 under Q17. (proposed) [sources: tests/test_k8s_rbac_audit.py:16]
- Where do the stack tables go?: Into a public module in
k8s/(for examplek8s/stacks.py). The manifest invariant tests and the commands then read the same public names. The stack names are defined once ink8s/and not duplicated acrossnetworking.pyandstack_lifecycle.py. (proposed) [sources: src/devops_cli/commands/k8s/stack_lifecycle.py:54, src/devops_cli/commands/k8s/stack_lifecycle.py:78, src/devops_cli/commands/k8s/stack_lifecycle.py:168, src/devops_cli/commands/k8s/stack_lifecycle.py:201, src/devops_cli/commands/k8s/networking.py:60] - Is this one pull request?: No. The scope spans 14 test files (5,585 lines, 238 tests), deletion of the
_K8sModulepatch-forwarding class, moving stack catalogue and URL resolution logic tok8s/, adopting five seam issues (refactor(cli): one process runner owns execution, process groups and dry-run #775, refactor(k8s): KubernetesService is the Kubernetes API seam, with a shared fake cluster and its contract suite #1315, refactor(security): one keyring seam owns the keyring and the Secret Service lock check, with a shared keyring fake and its contract suite #1318, refactor(cli): tests control time: time-machine fakes wall-clock reads, and retry and rate-limit waits return at once and are recorded #1320, test(cli): the hermetic floor fails a test that reaches an edge without a fake and resets all process-wide state after every test #1310), dissolvingtest_k8s.pyinto behaviour files, and adding syrupy snapshots. This exceeds one pull request and is split. (proposed) [sources: src/devops_cli/commands/k8s/init.py:245, src/devops_cli/commands/k8s/init.py:253] - Does the single kubectl/helm argv builder always resolve the context through
resolve_context?: Yes. The builder adds--contextfor kubectl and--kube-contextfor helm.resolve_effective_contextis deleted. Tests cover the context-passing paths atcluster_context.py:203andsecurity_audit.py:44. (proposed) [sources: src/devops_cli/k8s/context.py:78, src/devops_cli/commands/k8s/cluster_context.py:150, src/devops_cli/commands/k8s/cluster_context.py:203, src/devops_cli/commands/k8s/security_audit.py:44]
Fit
Needs splitting into 6 items:
- Remove
_K8sModulepatch forwarding and makecommands/k8s/__init__.pyexport only public names - Move stack catalogue, URL resolution, proxy targets and host overrides into
k8s/domain modules under public names - Route kubectl, helm, minikube and port-forward through the refactor(cli): one process runner owns execution, process groups and dry-run #775 process runner; delete per-module wrappers
- Route Kubernetes clients through refactor(k8s): KubernetesService is the Kubernetes API seam, with a shared fake cluster and its contract suite #1315, keyring through refactor(security): one keyring seam owns the keyring and the Secret Service lock check, with a shared keyring fake and its contract suite #1318, waits through refactor(cli): tests control time: time-machine fakes wall-clock reads, and retry and rate-limit waits return at once and are recorded #1320, and settings through test(cli): the hermetic floor fails a test that reaches an edge without a fake and resets all process-wide state after every test #1310's config fixture
- Rewrite the 14 test files to use public interfaces and process fakes; dissolve
test_k8s.pyinto behaviour files; deletetest_subsystem_containment_and_redaction.py - Add syrupy snapshots for dry-run previews and command output; enforce 90% coverage
Suspected block
None.
Dependencies
Alternatives check of 2026-10-29: not-applicable.
Tool: none found.
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsNew
- StatusShow more project fieldsNew
Activity
dan-petty commentedon Oct 8, 2026
Found by the 2026-10-08 client-library audit (05e9388).
Kubernetes CLI calls that pass no
--context/--kube-contextrun against the ambientkubectlcurrent-context. Native client calls usesettings.k8s.contextthroughk8s/context.resolve_context, so the two can target different clusters in one command.Sites:
commands/k8s/:cluster_context.py:150and:203(kubectl apply);cluster_context.py:329(kubectl logs). Its native path_stream_native_pod_logs(:345) uses the configured context, so the fallback can read another cluster.security_audit.py:44(RBACkubectl get).commands/kustomize.py::49,:84,:99(build_kubectl_cmdcalled withoutcontext).config/commands.py:264:build_helm_diff_cmdhas no--kube-context.k8s/(test(k8s): k8s/ is tested through its public interface over the Kubernetes API, process, HTTP and keyring fakes, with no internal patches or private imports #1322's package):logs.py:71;logql.py:259and:321;security_stream.py:159;chaos.py:72,:97,:107;chaos_runner.py:66,:118.ai/(other items' packages):gateway.py:314;tools/builtin_tools.py:221,:229.Proposed criterion for this item: the single kubectl/helm argv builder that replaces the per-module wrappers always resolves the context through
resolve_contextand adds--context(--kube-contextfor helm). The sites above in other packages adopt it with their own items.dan-petty-bot commentedon Oct 8, 2026
Closed as a duplicate of #1322:
Both ask to refactor k8s test files to use edge fakes over the public interface and eliminate internal patches and private imports; the candidate's 14 commands/k8s test files and _K8sModule removal are a subset of #1322's 18-file k8s scope.If it is not a duplicate, reopen it: intake then places it without the duplicate check.
dan-petty commentedon Oct 24, 2026
Reopened. This issue was closed as a duplicate on 2026-10-08 with no box ticked, and no other issue owns its scope.
Evidence from the test-suite audit of 2026-10-24 (counts at df8e2ee, lines at b170358):
_K8sModulepatch forwarding is still insrc/devops_cli/commands/k8s/__init__.py:228-258._PATCH_TARGET_MAPis at:228, the class at:250, and the module swaps its own class at:258(sys.modules[__name__].__class__ = _K8sModule). docs/TESTING.md says that product code holds no module shaped so that a test can patch it.devops_cliinternals belong to this issue's files:tests/test_k8s.py131,tests/test_k8s_context.py38,tests/test_k8s_networking.py21,tests/test_k8s_logging_stack.py20,tests/test_k8s_proxy_addressing.py11,tests/test_k8s_runtime_cmd.py9,tests/test_k8s_qdrant_security.py7,tests/test_k8s_bootstrap.py2.tests/test_k8s_network_policies.py,tests/test_subsystem_containment_and_redaction.pyandtests/test_k8s_argocd_apps.py.tests/test_k8s.pyalone holds 33.k8s/, notcommands/k8s/.Under the owner's rule of 2026-10-24 (#2143), the tests of this issue also start no program. The git and kubectl starts in
tests/test_k8s.pygo with the k8s issue of the same audit and with the issue that turns the kustomize renders into adevops cirow.dan-petty commentedon Oct 28, 2026
The proposal at 69636b6 needs splitting into 6 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.
_K8sModulepatch forwarding and makecommands/k8s/__init__.pyexport only public namesk8s/domain modules under public namestest_k8s.pyinto behaviour files; deletetest_subsystem_containment_and_redaction.pyrefactor(k8s): KubernetesService is the Kubernetes API seam, with a s…
devops-cli-service commentedon Oct 30, 2026
Alternatives check: not-applicable
Tool: none found
Checked on 2026-10-29. A person decides what this means for the item. The check changes no label and closes no issue.