Skip to content

refactor: delete the dead code that #1910 kept #5148

Done

Description

@dan-petty

Problem

#1910 deleted the src symbols that only tests call, but it kept some dead code because a deletion needs a spec decision, a standards change, a test rewrite or the end of other open work. No public behaviour reaches this code:

  • _read_event_stream and _event_frames (src/devops_cli/ai/client/streaming.py): no provider reads a server-sent event stream with them. The stream contract tests in tests/ai/client/test_ai_streaming.py drive them and the NDJSON reader through one table of about ten tests, with a frame parser that the test file holds.
  • _parse_and_validate_scheme (src/devops_cli/core/validation.py): no caller. The spec configured-service-urls names it in the requirement "A URL error text never holds the configured URL".
  • can_transition and _VALID_TRANSITIONS (src/devops_cli/review/state.py): no caller enforces the table. The spec review-finding-state holds the requirement "Lifecycle state transitions allow CONFIRMED to OPEN".
  • run_json_subprocess (src/devops_cli/core/process.py): no caller. docs/SDLC.md and docs/ROUTINE_TASKS.md tell new code to use it.
  • _run_gh_pr_command and _resolve_pr_head_sha (src/devops_cli/commands/pr.py): no caller. The deletion of devops pr update changes this file now.
  • The cache of ResourceInformer (src/devops_cli/k8s/informer.py): the informer fills it, and only get_state and get_cached_resources read it, which only tests call.
  • ResourceSubscriptionManager.subscribe (src/devops_cli/ai/mcp/dispatcher.py): no caller in src, so notify reaches no listener.
  • AgentRetries and AgentStepNode (src/devops_cli/ai/agents/context.py) and AgentResponse (src/devops_cli/ai/agents/models.py): left by refactor(ai): replace PydanticAgent with pydantic-ai Agent #4237, no caller in src.

Evidence

uvx vulture src (vulture 2.16) lists each name as unused, and git grep -w finds no caller in src, docs, the knowledge base, pyproject.toml or the workflows. The design of #1910 records why that change kept each one.

Remedy

For each group, decide and delete:

  • Delete the server-sent event reader and its rows of the stream contract table.
  • Remove the two spec scenarios with a REMOVED or MODIFIED requirement, and delete the two functions.
  • Change the two documents to name run_subprocess with extract_json_block, and delete run_json_subprocess.
  • Delete the two commands/pr.py helpers after the deletion of devops pr update merges.
  • Delete the informer cache, the subscription manager's dead half and the three agent models, with the tests that only read them.

Do not add vulture as a gate.

Source: #1910

Alternatives check of 2026-11-16: not-applicable.
Class: refactor, no search.
Tool: none found.

Proposed design

Problem statement

Delete the dead code that #1910 kept, except two groups that wait on other work: the commands/pr.py helpers wait on the deletion of devops pr update, and the names that #4849 leaves dead wait on #4849. Each waiting group goes to its own new issue. The rest of the deletion, its two spec removals and its two document updates fit in one pull request.

Acceptance criteria

Requirement: Event-stream reader removed

The AI client streaming module SHALL hold no _read_event_stream function and no _event_frames function.

Scenario: The streaming module has no event reader

  • WHEN a test imports devops_cli.ai.client.streaming and looks up _read_event_stream and _event_frames
  • THEN hasattr returns False for both names

Requirement: Stream table drops the event rows

The stream contract tests MUST hold no row that imports _read_event_stream.

Scenario: No test names the deleted reader

  • WHEN a developer runs git grep -rw _read_event_stream src tests
  • THEN the command prints no match

Requirement: Validation helper removed

The core validation module SHALL hold no _parse_and_validate_scheme function.

Scenario: The validation module has no scheme parser

  • WHEN a test imports devops_cli.core.validation and looks up _parse_and_validate_scheme
  • THEN hasattr returns False

Requirement: URL error requirement removed

The configured-service-urls spec MUST hold no requirement with the text A URL error text never holds the configured URL.

Scenario: The living spec drops the URL error requirement

  • WHEN a developer runs git grep -rF 'A URL error text never holds the configured URL' openspec/specs
  • THEN the command prints no match

Requirement: State transition table removed

The review state module SHALL hold no can_transition function and no _VALID_TRANSITIONS table.

Scenario: The state module has no transition check

  • WHEN a test imports devops_cli.review.state and looks up can_transition and _VALID_TRANSITIONS
  • THEN hasattr returns False for both names

Requirement: Transition requirement removed

The review-finding-state spec MUST hold no requirement that states a lifecycle transition rule.

Scenario: The living spec drops the transition requirement

  • WHEN a developer runs git grep -rF 'transitions allow' openspec/specs
  • THEN the command prints no match

Requirement: Process helper removed

The core process module SHALL hold no run_json_subprocess function.

Scenario: The process module has no JSON helper

  • WHEN a test imports devops_cli.core.process and looks up run_json_subprocess
  • THEN hasattr returns False

Requirement: Documents name the live helper

The two SDLC documents MUST name run_subprocess with extract_json_block and no run_json_subprocess.

Scenario: The documents point at the live helper

  • WHEN a developer runs git grep -rw run_json_subprocess docs
  • THEN the command prints no match, and git grep -n run_subprocess docs/SDLC.md docs/ROUTINE_TASKS.md shows the name in both files

Requirement: Informer cache removed

The ResourceInformer class SHALL hold no cache and no get_state or get_cached_resources method.

Scenario: The informer has no cache reader

  • WHEN a test imports devops_cli.k8s.informer and looks up ResourceInformer.get_state and ResourceInformer.get_cached_resources
  • THEN hasattr returns False for both methods

Requirement: Subscription manager dead half removed

The ResourceSubscriptionManager class SHALL hold no subscribe method.

Scenario: The manager has no subscribe method

  • WHEN a test imports devops_cli.ai.mcp.dispatcher and looks up ResourceSubscriptionManager.subscribe
  • THEN hasattr returns False

Requirement: Agent models removed

The agent context and model modules SHALL hold no AgentRetries, AgentStepNode or AgentResponse.

Scenario: The agent modules have no unused model

  • WHEN a test imports devops_cli.ai.agents.context and devops_cli.ai.agents.models and looks up the three names
  • THEN hasattr returns False for each name

Existing Tool Considered

The alternatives check of 2026-11-16 in the issue body gives the verdict not-applicable: class refactor, no search, Tool: none found (see that block). No open tool or library covers a deletion, and the change builds no code. The detector of the dead names is uvx vulture 2.16, which the issue body cites; the change adds it as no gate and as no dependency.

Key questions

  • Which names of the AI client stream reader are dead, and what keeps them alive now?: _read_event_stream and _event_frames have no caller in src. Only tests/ai/client/test_ai_streaming.py imports _read_event_stream, and it maps the anthropic protocol to it, so those rows of the table go with the reader. _read_ndjson_stream keeps its caller and its Ollama rows. [sources: src/devops_cli/ai/client/streaming.py, tests/ai/client/test_ai_streaming.py]
  • What do the two documents name in place of run_json_subprocess?: run_subprocess with extract_json_block. The two documents must name that pair, and the module keeps run_subprocess. (best practice) [sources: src/devops_cli/core/process.py, docs/SDLC.md, docs/ROUTINE_TASKS.md]
    • Rejected: keep run_json_subprocess. No caller, so the helper stays dead and the documents point at dead code.
    • Chosen: delete it and name run_subprocess with extract_json_block. This is the helper that src calls, so the documents teach the live path.
    • Rejected: delete it and say nothing. The documents would still teach a helper that does not exist.
  • Do the two spec requirements stay, change, or go?: Both go. No caller enforces either one, so the text states a behaviour that the code does not have. The change's spec delta removes A URL error text never holds the configured URL from configured-service-urls and the transition requirement from review-finding-state, and the archive writes the living specs. (best practice) [sources: openspec/specs/configured-service-urls/spec.md, openspec/specs/review-finding-state/spec.md, src/devops_cli/core/validation.py, src/devops_cli/review/state.py]
    • Rejected: keep the requirements and wire the code. No caller enforces the table, so the wiring is new behaviour and out of this deletion's scope.
    • Rejected: keep the requirement text. The text would state a behaviour that no code has.
    • Chosen: remove both with a REMOVED requirement in the change delta. The living spec then states only behaviour that the code has.
  • Does vulture become a gate?: No. The issue body says not to add it, and ADR 0004 pins the required checks to Static Analysis and Tests & Coverage. A developer runs uvx vulture src to find the names, and no workflow runs it. (best practice) [sources: docs/adr/0004-ci-is-the-authoritative-gate.md]
    • Rejected: add a CI row for vulture. A new gate needs a ruleset change, and ADR 0004 names the two required checks.
    • Chosen: run uvx vulture by hand. This gives the evidence of the dead names with no new gate and no new dependency.
    • Rejected: use no detector. The issue needs evidence that each name has no caller.
  • What happens to the informer cache and the subscription manager?: Delete the cache and its two read methods from ResourceInformer, and delete ResourceSubscriptionManager.subscribe with the listener collection that only it writes. Keep the informer's watch, its typed models, and notify if a caller remains. (best practice) [sources: src/devops_cli/k8s/informer.py, src/devops_cli/ai/mcp/dispatcher.py, tests/k8s/test_k8s_service.py, tests/k8s/test_kubernetes_contract.py]
    • Rejected: keep both. No caller in src reads either one, so they stay dead.
    • Rejected: delete only the cache. subscribe writes a listener list that nothing reads.
    • Chosen: delete both dead halves. Each deleted name loses its last caller, and the live watch path stays.
  • What happens to AgentRetries, AgentStepNode and AgentResponse?: Delete them. AgentRetries is at src/devops_cli/ai/agents/context.py:28, AgentStepNode at :89, and AgentResponse at src/devops_cli/ai/agents/models.py:16. Each name appears only in its own module. [sources: src/devops_cli/ai/agents/context.py:28, src/devops_cli/ai/agents/context.py:89, src/devops_cli/ai/agents/models.py:16]
  • Does the reply's added scope belong in this change?: No. The five names still have callers in src until refactor: delete the src symbols that only tests call #4849 merges, so a deletion now breaks the build. The part goes to a new issue that waits on refactor: delete the src symbols that only tests call #4849. (best practice) [sources: src/devops_cli/ai/review/pipeline.py:700, src/devops_cli/security/vault_lease.py:41, src/devops_cli/ai/rag/embeddings.py:1342, tests/ai/agents/test_ai_agent_capabilities.py:73]
  • Do the two commands/pr.py helpers belong in this change?: No. The issue body orders their deletion after the deletion of devops pr update, which changes the same file. The part goes to a new issue that waits on that deletion. (best practice) [sources: src/devops_cli/commands/pr.py]
    • Rejected: delete them now. The callers in devops pr update still exist until that command goes.
    • Chosen: defer them to a new issue. This change then holds no file that the devops pr update deletion also changes.

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

None.

Moved to new items

#6492, #6493

Activity

  1. added
    source/agent
    on Nov 12, 2026
  2. added
    type/refactor
    status/new
    value/medium
    effort/medium
    on Nov 12, 2026
  3. dan-petty commented on Nov 12, 2026

    @dan-petty
    OwnerAuthor
  4. added
    priority/p3-low
    on Nov 12, 2026
  5. dan-petty commented on Nov 12, 2026

    @dan-petty
    OwnerAuthor

    Add these to the scope (found by the independent review of #4849): names that only code deleted in #4849 used, so they are dead after it merges.

    • src/devops_cli/ai/review/pipeline.py:700 _VERSION_RANGE_MARKERS and :702 _VERSION_WILDCARD (only the deleted _is_exact_version used them)
    • src/devops_cli/security/vault_lease.py:41 _VAULT_AUTH_LOGIN_PATH (only the deleted track_auth used it)
    • src/devops_cli/ai/rag/embeddings.py:1342 EmbeddingCost and :1350 EmbeddingResult (about 100 lines; now used only by tests/ai/agents/test_ai_agent_capabilities.py:73-100). Vulture misses these because from pydantic_ai.embeddings import EmbeddingResult as PydanticEmbeddingResult counts as a use of the name.
  6. devops-cli-service commented on Nov 16, 2026

    @devops-cli-service
    Contributor

    Alternatives check: not-applicable

    Class: refactor. The check makes no search and no model call for an item of this class.

    Tool: none found

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

  7. added
    status/ready
    and removed
    status/new
    on Nov 20, 2026
  8. devops-cli-service commented on Nov 20, 2026

    @devops-cli-service
    Contributor

    Next step: the stage job writes the plan of the item. See Moved to new items in the section Proposed design of the body.

  9. added
    owner/agent
    status/in-progress
    status/in-review
    and removed
    status/ready
    status/in-progress
    on Nov 28, 2026
  10. removed
    status/in-review
    owner/agent
    on Nov 28, 2026
  11. devops-cli-service commented on Nov 29, 2026

    @devops-cli-service
    Contributor

    Live since 2026-11-29 00:41 UTC

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/p3-lowsource/agenttype/refactorvalue/medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions