Skip to content

test(cli): the infra commands are thin adapters tested over edge fakes, with no internal patches or private imports #1327

Closed

Description

@dan-petty

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 (17; 5,057 lines, 257 tests [measured: AST pass at 5c45b1e]).
  • Coupling. These files hold 185 internal patch sites (15 files) and 18 private imports (10 files) [measured]. One invariant test adds a private import of commands.config._detect_keyring_secret_leaks [code: tests/test_zero_plaintext_invariants.py:7].
    • Most-patched internals: load_settings 37 (cloudflare 18, config 7, prometheus 6, argo 3, grafana 3); commands.valkey._resolve_client 20; tf._resolve_tf_binary 15; cloudflare._resolve_client 14; telemetry.query_jaeger_trace 8; vault.VaultSecretBroker 8; tf.is_dry_run 7, patched where tests could pass --dry-run; telemetry.get_tracer 4.
    • test_telemetry_cmd.py patches the tracer's private _send_payload and its test_connection [code: tests/test_telemetry_cmd.py:41-43, :54-56].
    • Edge patches, 55 sites: httpx2 17, subprocess.run 13, keyring 10, shutil.which 6, typer.prompt and typer.confirm 4, socket.getaddrinfo 3, docker.from_env 1, time.sleep 1.
    • test_valkey.py fakes the RESP socket in its own helper (:127), and all 17 files build a module-level runner = CliRunner().
  • Edges outside a seam.
    • 15 inline httpx2 clients:
      • commands/argo.py:203, :256, :285;
      • commands/grafana.py:106, :158, :219, :334, :452, :492, :529;
      • commands/prometheus.py:144, :198, :280, :334, :376.
    • commands/config.py imports the keyring library [code: commands/config.py:530] and the private config.settings._keyring_has [code: commands/config.py:22, :533].
    • ValkeyClient is built inside _resolve_client [code: commands/valkey.py:36, :47], and commands/ai_ingest.py:224 imports that function privately.
    • Waits use time.sleep [code: commands/telemetry.py:279, :367; commands/argo.py:129].
  • Logic living in commands/ (Q19).
  • Names.
    • Catch-alls: test_prometheus.py:126, test_valkey.py:742, test_docker.py:171, test_config_commands.py:211.
    • 33 test names end in _success, _failure, _basic or _command.

Acceptance criteria

Key questions

Strategic alignment

Proposed design

Problem statement

The infra command tests patch internal functions and import private modules. This makes tests fragile and hard to maintain.

Acceptance criteria

  • Criterion 1: Test files under tests/commands/ have zero internal patch sites or private imports.
    Verification: Run the test suite with no patch sites or private imports in the test files owned by this item.
  • Criterion 2: All edges go through seams using fake implementations.
    Verification: Verify that all HTTP, DNS, process, keyring and other external calls are faked through designated seam items.
  • Criterion 3: Logic moves out of commands/ directory to public functions.
    Verification: Check that Terraform resolution, secret-leak detection, Cloudflare bypass-IP resolution, and Vault path validation move to public functions in tf/, config/, cloudflare/, and security/ directories.
  • Criterion 4: CLI tests use shared cli fixture and syrupy snapshots for output.
    Verification: Confirm that CLI tests use the shared cli fixture and assert on full values using syrupy snapshots.

Key questions

Open questions

  • Which files belong to this item? (missing verified source)

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

#1313, #1314, #1315, #1316, #1317, #1318, #1319

Alternatives check of 2026-10-30: not-applicable.
Tool: none found.

Activity

  1. added
    type/test
    scope/cli
    scope/config
    priority/p2-medium
    scope/infra
    on Oct 7, 2026
  2. 5 remaining items

  3. dan-petty commented on Oct 26, 2026

    @dan-petty
    OwnerAuthor

    Intake placed this item to the backlog: intake puts every new item in the backlog. A person plans the milestones on the board.

    • Priority: P1-High. This change improves the quality and maintainability of infrastructure command tests.
    • Value: High. Improving test quality impacts all users by increasing reliability and reducing bugs.
    • Effort: Medium. Requires moderate effort to refactor tests and remove internal patches and private imports.
    • Possible duplicate: test(infra): infrastructure tests run on edge fakes #1335, which may ask for the same change. The model names infra commands are thin adapters tested over edge fakes, with no internal patches or private imports as the change that both ask for. The candidate and item #1335 both ask for the same change of infra commands being thin adapters tested over edge fakes with no internal patches or private imports. A person closes one of the two if that is so.
  4. dan-petty commented on Oct 27, 2026

    @dan-petty
    OwnerAuthor

    Refine cannot set this item to Ready at 518db63 until a person answers the questions below. Reply in a comment or edit the body, and the next refine round looks at the item again.

    • Which files belong to this item? (missing verified source)
  5. added
    priority/p1-high
    status/new
    effort/medium
    value/high
    and removed
    priority/p2-medium
    on Oct 28, 2026
  6. devops-cli-service commented on Oct 30, 2026

    @devops-cli-service
    Contributor

    Alternatives check: not-applicable

    Tool: none found

    Checked on 2026-10-30. A person decides what this means for the item. The check changes no label and closes no issue.

  7. removed
    status/new
    on Oct 31, 2026
  8. dan-petty commented on Nov 29, 2026

    @dan-petty
    OwnerAuthor

    Plan PR #2872 merged and closed this issue on 2026-10-31 before any implementation task ran. All implementation and verification groups in openspec/changes/1327-infra-commands-edge-fakes/tasks.md stayed open (0 of 5 task groups completed, 0 of 29 checkboxes ticked):

    1. Domain Logic Extraction — move Terraform binary resolution from src/devops_cli/commands/tf.py (which still holds _resolve_tf_binary), secret-leak checks from src/devops_cli/commands/config.py, and Cloudflare bypass-IP and Vault path helpers into domain packages.
    2. Refactor Config and Vault Command Tests — move test_config_cmd.py, test_config_commands.py, test_config_audit_keys.py, and test_vault_cmd.py onto cli and edge fakes with zero internal monkeypatches.
    3. Refactor Terraform, Kustomize, and Docker Command Tests — move test_tf.py, test_tf_notify_plan.py, test_kustomize.py, and test_docker.py onto process_fake, --dry-run, and edge fakes.
    4. Refactor Telemetry and Metrics Command Tests — move test_telemetry_cmd.py, test_telemetry_profile.py, test_prometheus.py, and test_grafana.py onto OTLP and HTTP edge fakes.
    5. Refactor Network and Runtime Command Tests — move test_cloudflare_commands.py, test_argo.py, test_valkey.py, test_tls_cmd.py, and test_scan.py onto edge fakes.
    6. Verification and Change Archival — run invariant and command test gates.

    Where this work is now: Open Phase E tracker #1335 covers this migration across infrastructure packages and commands/ (specifically proposed children 4, 5, and 6 covering sandbox, docker, tf, watchers, argo, cloudflare, prometheus, and grafana). As part of #7356, the stale folder openspec/changes/1327-infra-commands-edge-fakes/ was removed.

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

    effort/mediumpriority/p1-highscope/cliscope/configscope/infratype/testvalue/high

    Type

    No type

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions