Skip to content

refactor: Delete unused functions after manual caller check #1910

Closed
1 of 1 issue completed
Closed

Description

@dan-petty

Problem

The vulture trial of #1871 found 19 functions and methods in src that appear only at their definition in src and tests. Each may be dead code. Each needs a manual check before anyone deletes it.

Evidence

The list, with the line of each definition on the tip at the time (docs/agent/tasks/task-1871-tombstone-tests-and-dead-code-tool.md holds the same list):

  • run_stream_async at src/devops_cli/ai/agents/agent.py:1244
  • validate_slot at src/devops_cli/ai/harness/slots.py:82
  • _is_mutating_tool at src/devops_cli/ai/harness/slots.py:226
  • validate_invariants at src/devops_cli/ai/harness/slots.py:748
  • active_resources at src/devops_cli/ai/mcp/dispatcher.py:156
  • record_rejection at src/devops_cli/ai/review/profile.py:203
  • _unique_preserve_order at src/devops_cli/ai/review/sanitization.py:13
  • _tokenize_title at src/devops_cli/ai/review_schema.py:148
  • less_severe at src/devops_cli/ai/review_schema.py:624
  • remove_custom_pricing at src/devops_cli/ai/spend/pricing.py:552
  • should_ignore_dir at src/devops_cli/argo/gitops.py:68
  • _extract_policy_include_email at src/devops_cli/cloudflare/client.py:219
  • _run_gh_pr_command at src/devops_cli/commands/pr.py:98
  • _resolve_pr_head_sha at src/devops_cli/commands/pr.py:320
  • _render_logs_json at src/devops_cli/commands/sandbox.py:943
  • _extract_roadmap_versions at src/devops_cli/docs/compactor.py:222
  • get_last_request_epoch at src/devops_cli/github/rate_limiter.py:903
  • _is_numbered at src/devops_cli/review/diff.py:68
  • is_p1 at src/devops_cli/roadmap/reprioritize.py:499

#1952 deleted src/devops_cli/docs/compactor.py and src/devops_cli/roadmap/reprioritize.py. So _extract_roadmap_versions and is_p1 are gone, and 17 names remain.

Two other findings, get_native_tools and get_description in src/devops_cli/ai/agents/capabilities.py, are live Pydantic AI hooks. Five more names share a word with another object and need the same check: argo_app_status, set_mcp_sampling_model, to_cli, traces and merge. Some of these functions belong to code that other open items delete (for example the rate limiter and the harness).

Remedy

For each name, search src, tests, the docs, the knowledge base and the entry points for a caller (a string, a registry or a framework hook counts). Delete the functions with no caller, with the tests that only call them. Skip a name that another open item deletes. Do not add vulture as a gate: the trial needed 12 decorator patterns and 7 name patterns first.

Alternatives check of 2026-11-01: not-applicable.
Tool: none found.

Proposed design

Problem statement

The vulture trial found 19 dead-code candidates in src. #1952 removed 2 of them, so 17 names remain. A later CI audit measured 129 src symbols that only tests use, and at least 26 of those tests are false positives. This change checks each symbol for a production caller and deletes each confirmed dead symbol with its tests. It leaves out test helpers, unwired code, invariant and gate helpers, and code that another open item deletes. It does not add vulture as a gate.

Acceptance criteria

Requirement: Deletion evidence

The pull request MUST state, for each deleted symbol, that no production caller exists in src, an entry point or a framework hook.

Scenario: A deleted symbol records its evidence

  • WHEN The pull request deletes a symbol.
  • THEN The pull request body lists the symbol and states that its only references are tests.

Requirement: Dead symbol removal

A symbol with no production caller SHALL be deleted from src.

Scenario: No production caller

  • WHEN A search of src, docs, the knowledge base and the entry points finds no caller of the symbol.
  • THEN The symbol no longer appears in src.

Requirement: Test removal

A test that only calls a deleted symbol SHALL be deleted with it.

Scenario: The test of a deleted symbol

  • WHEN A test module only calls a symbol that the change deletes.
  • THEN The test module or the test case no longer appears in tests.

Requirement: False positives stay

The change MUST NOT delete wait_active, build_allowlist, or an invariant or gate helper.

Scenario: A false positive stays in the tree

  • WHEN The pull request diff is inspected.
  • THEN wait_active and build_allowlist still appear in the tree.

Requirement: Code other items delete stays

The change MUST leave src/devops_cli/github/rate_limiter.py and src/devops_cli/ai/harness/slots.py unchanged.

Scenario: Rate limiter and harness untouched

  • WHEN The pull request diff is inspected.
  • THEN Neither file has a change.

Requirement: No vulture gate

The change MUST NOT add vulture as a CI gate or a required check.

Scenario: No vulture step

  • WHEN The pull request diff is inspected.
  • THEN No vulture step appears in .github/workflows/ or .github/roadmap.toml.

Requirement: Suite and mypy pass

The full test suite and mypy MUST pass after the deletions.

Scenario: Required checks pass

  • WHEN The Tests & Coverage and Static Analysis checks run on the pull request.
  • THEN Both checks pass.

Existing Tool Considered

The alternatives check returned not-applicable because this item is a refactor, which is a skip class. vulture (https://github.com/jendrikseipp/vulture) is the open, maintained dead-code finder that produced the candidate list. It lacks dynamic-use detection: it cannot see a framework hook, a registry entry or a string caller. Its trial needed 12 decorator patterns and 7 name patterns before its list was usable. The change uses vulture only to list candidates and does not add it as a gate.

Key questions

  • Which tool finds the dead-code candidates, and does the change adopt it as a gate?: vulture finds the candidates. The alternatives check returned not-applicable because the item is a refactor. vulture lacks dynamic-use detection and needed 12 decorator patterns and 7 name patterns before its list was usable. The change does not add vulture as a gate. (best practice) [sources: docs/TESTING.md]
    • Rejected: Add vulture as a CI gate. The trial needed 12 decorator patterns and 7 name patterns, and vulture misses dynamic use.
    • Chosen: Use vulture to list candidates and check each caller by hand. The body and the CI audit say not to add a gate, and each deletion needs evidence.
    • Rejected: Build a custom dead-code finder. It adds code to keep and fix, and vulture already finds the candidates.
  • What is the scope of the caller check after the CI audit?: The scope is the 129 src symbols that only tests use. The check leaves out the false positives: wait_active, build_allowlist of feat(roadmap): allow-list builder for planner read-only commands #4004, and the architecture invariant helpers. It also leaves out the invariant and gate helpers and the code that is not yet wired. The 5 names that share a word with another object get the same check. (best practice) [sources: docs/TESTING.md]
    • Rejected: Keep the 17 named functions only. The CI audit measured 129 symbols and set the new scope.
    • Chosen: Use the 129-symbol audit list, minus false positives and exclusions. It is the latest measured list, and it keeps the named 17.
    • Rejected: Delete every vulture finding with no read. At least 26 findings are false positives.
  • How does a checker decide that a symbol is dead?: Search src, docs, the knowledge base and the entry points for the name. A string, a registry entry or a framework hook counts as a caller. A reference in a test does not count. Delete the symbol when no production caller exists. (best practice) [sources: docs/TESTING.md]
    • Rejected: Search src and tests only. A string, a registry entry or a framework hook in docs or an entry point is a caller.
    • Chosen: Search src, docs, the knowledge base and the entry points. The body and the CI audit name these sources.
    • Rejected: Trust vulture with no manual read. vulture does not see dynamic use.
  • What happens to the tests of a deleted symbol?: Delete the tests with the symbol. docs/TESTING.md says to delete dead code. The full suite and mypy must pass after the deletion. (best practice) [sources: docs/TESTING.md]
    • Rejected: Keep the tests. A test of a deleted symbol cannot pass.
    • Chosen: Delete the tests with the symbol. docs/TESTING.md says to delete dead code, and the suite must pass.
  • Are the symbols in the rate limiter and the harness in scope?: No. Another open item deletes the rate limiter and the harness. This change leaves src/devops_cli/github/rate_limiter.py and src/devops_cli/ai/harness/slots.py unchanged. (best practice) [sources: src/devops_cli/github/rate_limiter.py, src/devops_cli/ai/harness/slots.py]
    • Rejected: Delete them in this change. Another open item deletes these files, so a change here conflicts.
    • Chosen: Skip them and leave the files unchanged. The body says to skip a name that another open item deletes.

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

None.

Sub-issues

Sub-issues

1 of 1 Issues completed
Loading 1 sub-issues

Activity

  1. added
    source/agent
    type/refactor
    on Oct 22, 2026
  2. dan-petty commented on Oct 22, 2026

    @dan-petty
    OwnerAuthor

    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.

    • Type: type/refactor. The candidate proposes to delete dead code, which is a refactor.
    • Priority: P2-Medium. This is a hygiene task that improves code quality but does not block other work or fix an urgent issue.
    • Value: Medium. Removing unused code improves maintainability and reduces confusion for developers, but it's not critical to users.
    • Effort: Low. Each function requires a manual check for callers, but the work is straightforward once identified.
  3. dan-petty commented on Oct 28, 2026

    @dan-petty
    OwnerAuthor

    Refine cannot set this item to Ready at bb46660 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 of the 17 remaining names have no caller in src, tests, docs, the knowledge base, or entry points? (missing verified source)
  4. added
    priority/p2-medium
    status/new
    value/medium
    effort/low
    on Oct 28, 2026
  5. added 2 commits that reference this issue on Nov 1, 2026
  6. devops-cli-service commented on Nov 1, 2026

    @devops-cli-service
    Contributor

    Alternatives check: not-applicable

    Tool: none found

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

  7. 5 remaining items

  8. devops-cli-service commented on Nov 11, 2026

    @devops-cli-service
    Contributor

    Status set to Ready at 5c71ad4 (see proposed design in issue body).

  9. devops-cli-service commented on Nov 11, 2026

    @devops-cli-service
    Contributor

    Staged: branch refactor/1910-delete-unused-functions-after-manual-caller, draft pull request #4849. The pull request plans the item and closes no issue.

    The task groups, with the tokens of the inputs of each step, for a budget of 64000 tokens:

    1. Delete the unused order helper of the review sanitization: 16818 tokens
    2. Delete the unused rejection recorder of the review profile: 19786 tokens
    3. Delete the unused title tokenizer: 22874 tokens
    4. Delete the unused severity comparator: 22873 tokens
    5. Delete the unused result merge: 28477 tokens
    6. Delete the unused dispatcher resource list: 18197 tokens
    7. Delete the unused GitOps directory filter: 18144 tokens
    8. Delete the unused diff line check: 17556 tokens
    9. Delete the unused gh PR runner: 24117 tokens
    10. Delete the unused PR head lookup: 24115 tokens
    11. Delete the unused sandbox log JSON renderer: 20011 tokens
    12. Delete the unused Cloudflare policy email helper with its test: 23716 tokens
    13. Delete the unused pricing removal with its test: 23684 tokens
    14. Delete the unregistered Argo CD status tool with its test call: 18746 tokens
    15. Delete the unused engine trace method: 22271 tokens

    A model review of the plan found these open findings. The stage keeps this pull request a draft with the label plan/needs-fix until a later round clears them:

    • criterion_dropped at summary, what_changes and rejected: The issue's CI audit and proposed design make the scope the 129 src symbols that only tests use, minus false positives; the plan deletes only the 15 symbols of the original 19+5 list, so the other dead symbols have no task. The plan's rejected alternative 'Delete every symbol that vulture or the 129-symbol audit lists' is not the issue's chosen option, which keeps the 129 list minus the false positives and exclusions. Evidence: "The scope is the 129 src symbols that only tests use."
    • criterion_dropped at groups (every verify line): The issue requires the full test suite and mypy to pass after the deletions, but no group runs them; every group's verify is a single git grep, so the plan has no task for the criterion and only asserts in its feasibility that CI runs the checks. Evidence: "The full test suite and mypy MUST pass after the deletions."

    A model review of the plan found these points. They stop no draft, and a person judges them:

    • other at group 13: The group deletes the whole test_set_price_for_a_model_of_the_setting_wins_and_remove_restores_the_setting, but the test also asserts that the live set_custom_pricing beats the setting; the plan's own decision says to remove only the assertions of the deleted symbol when a test also covers other code, so this drops live coverage. Evidence: "assert (by_hand, removed, restored) == (9.0, True, 0.035)"
    • other at group 3: After the group deletes _tokenize_title, the module-level _TITLE_FILLER_WORDS has no caller, but the group deletes only 'the imports that only it used'; the constant and the CONST_REVIEW_TITLE_FILLER_WORDS import remain, so the group leaves dead code. Evidence: "_TITLE_FILLER_WORDS = CONST_REVIEW_TITLE_FILLER_WORDS"

    The runs of the planner and the review made 45 model request(s), and used 2902326 input tokens and 128401 output tokens. The tool calls, in order:

    1. read_issue({"number":1952})
    2. read_issue({"number":1871})
    3. read_issue({"number":4004})
    4. list_files({"directory":"src/devops_cli/ai/harness"})
    5. list_files({"directory":"src/devops_cli/github"})
    6. search_code({"text":"_is_numbered"})
    7. search_code({"text":"validate_slot"})
    8. search_code({"text":"_is_mutating_tool"})
    9. search_code({"text":"validate_invariants"})
    10. search_code({"text":"active_resources"})
    11. search_code({"text":"record_rejection"})
    12. search_code({"text":"_unique_preserve_order"})
    13. search_code({"text":"_tokenize_title"})
    14. search_code({"text":"less_severe"})
    15. search_code({"text":"remove_custom_pricing"})
    16. search_code({"text":"should_ignore_dir"})
    17. search_code({"text":"_extract_policy_include_email"})
    18. search_code({"text":"_run_gh_pr_command"})
    19. search_code({"text":"_resolve_pr_head_sha"})
    20. search_code({"text":"_render_logs_json"})
    21. search_code({"text":"get_last_request_epoch"})
    22. search_code({"text":"argo_app_status"})
    23. search_code({"text":"def traces"})
    24. search_code({"text":"def merge("})
    25. search_code({"text":"set_mcp_sampling_model"})
    26. search_code({"text":"to_cli"})
    27. file_symbols({"path":"src/devops_cli/commands/ci.py"})
    28. read_file({"path":"src/devops_cli/ai/tools/builtin_tools.py","start_line":240,"end_line":275})
    29. read_issue({"number":2175})
    30. find_issues({"terms":"rate_limiter"})
    31. find_issues({"terms":"harness slots"})
    32. read_file({"path":"src/devops_cli/commands/ci.py","start_line":1866,"end_line":1920})
    33. search_code({"text":".merge("})
    34. search_code({"text":"traces("})
    35. search_code({"text":"argo_apps"})
    36. read_file({"path":"src/devops_cli/commands/sandbox.py","start_line":805,"end_line":875})
    37. read_file({"path":"src/devops_cli/sandbox/engine.py","start_line":600,"end_line":640})
    38. read_file({"path":"tests/ai/spend/test_pricing_registry_overrides.py","start_line":120,"end_line":170})
    39. read_file({"path":"tests/cloudflare/test_client.py","start_line":830,"end_line":860})
    40. read_file({"path":"tests/security/test_builtin_tools.py","start_line":215,"end_line":240})
    41. search_code({"text":"def traces"})
    42. search_code({"text":"def merge("})
    43. search_code({"text":"def traces("})
    44. search_code({"text":"merge"})
    45. search_code({"text":"_is_numbered"})
    46. read_file({"path":"src/devops_cli/ai/review_schema.py","start_line":1130,"end_line":1175})
    47. search_code({"text":"traces"})
    48. references({"name":"merge"})
    49. search_code({"text":"merged_findings"})
    50. search_code({"text":"merge another"})
    51. read_file({"path":"src/devops_cli/sandbox/engine.py","start_line":600,"end_line":660})
    52. search_code({"text":"resolve_trace_spans"})
    53. search_code({"text":".traces("})
    54. list_files({"directory":"src/devops_cli/docs"})
    55. list_files({"directory":"src/devops_cli/roadmap"})
    56. list_files({"directory":"src/devops_cli/review"})
    57. search_code({"text":"_record_rejection"})
    58. search_code({"text":"_unique_preserve_order"})
    59. search_code({"text":"active_resources"})
    60. search_code({"text":"record_rejection"})
    61. search_code({"text":"_tokenize_title"})
    62. search_code({"text":"less_severe"})
    63. search_code({"text":"_is_numbered"})
    64. search_code({"text":".merge("})
    65. search_code({"text":"merged_findings"})
    66. search_code({"text":"remove_custom_pricing"})
    67. search_code({"text":"should_ignore_dir"})
    68. search_code({"text":"_extract_policy_include_email"})
    69. search_code({"text":"_run_gh_pr_command"})
    70. search_code({"text":"_resolve_pr_head_sha"})
    71. search_code({"text":"_render_logs_json"})
    72. search_code({"text":"argo_app_status"})
    73. search_code({"text":"def traces("})
    74. search_code({"text":"resolve_trace_spans"})
    75. search_code({"text":"def merge("})
    76. read_file({"path":"tests/security/test_builtin_tools.py","start_line":180,"end_line":270})
    77. read_file({"path":"src/devops_cli/commands/argo.py","start_line":320,"end_line":360})
    78. search_code({"text":".traces"})
    79. search_code({"text":"target_trace_id"})
    80. read_file({"path":"src/devops_cli/commands/sandbox.py","start_line":815,"end_line":900})
    81. list_files({"directory":"src/devops_cli/ai/agents"})
    82. list_files({"directory":"src/devops_cli/docs"})
    83. list_files({"directory":"src/devops_cli/roadmap"})
    84. search_code({"text":"set_mcp_sampling_model"})
    85. search_code({"text":"to_cli"})
    86. read_file({"path":"src/devops_cli/commands/sandbox.py","start_line":930,"end_line":1010})
    87. read_file({"path":"src/devops_cli/ai/review/profile.py","start_line":200,"end_line":260})
    88. search_code({"text":"traces("})
    89. search_code({"text":"engine.traces"})
    90. search_code({"text":"from devops_cli.ai.tools.builtin_tools import"})
    91. search_code({"text":"argo_apps"})
    92. read_spec({})
    93. read_file({"path":"src/devops_cli/commands/sandbox.py","start_line":1010,"end_line":1075})
    94. read_spec({"capability":"sandbox-logs"})
    95. search_code({"text":"validate_slot"})
    96. search_code({"text":"_is_mutating_tool"})
    97. search_code({"text":"validate_invariants"})
    98. search_code({"text":"get_last_request_epoch"})
    99. list_files({})
    100. search_code({"text":"knowledge base"})
    101. read_file({"path":"tests/cloudflare/test_client.py","start_line":820,"end_line":870})
    102. read_file({"path":"tests/ai/spend/test_pricing_registry_overrides.py","start_line":135,"end_line":175})
    103. read_file({"path":"src/devops_cli/cloudflare/client.py","start_line":190,"end_line":270})
    104. read_file({"path":"docs/agent/tasks/task-1871-tombstone-tests-and-dead-code-tool.md","start_line":1,"end_line":5})
    105. list_files({"directory":"docs/agent/tasks"})
    106. search_code({"text":"dead code"})
    107. read_file({"path":"src/devops_cli/ai/review_schema.py","start_line":1120,"end_line":1165})
    108. search_code({"text":"merged_conf"})
    109. search_code({"text":"set_custom_pricing"})
    110. read_issue({"number":1910})
    111. read_issue({"number":4405})
    112. find_issues({"terms":"rate_limiter"})
    113. find_issues({"terms":"harness slots"})
    114. search_code({"text":"_TITLE_FILLER_WORDS"})
    115. read_file({"path":"src/devops_cli/ai/review_schema.py","start_line":140,"end_line":160})
    116. read_file({"path":"src/devops_cli/ai/review_schema.py","start_line":615,"end_line":645})
    117. search_code({"text":"severity_named"})
    118. search_code({"text":"derive_recommendation"})
    119. search_code({"text":"sort_findings"})

    Tool calls: file_symbols=1 (empty=0), find_issues=4 (empty=2), list_files=10 (empty=0), read_file=22 (empty=0), read_issue=6 (empty=0), read_spec=2 (empty=0), references=1 (empty=0), search_code=73 (empty=2)

    The stage job read the open pull requests and their files in 1 GraphQL request(s).

  10. added
    owner/agent
    on Nov 12, 2026
  11. added 2 commits that reference this issue on Nov 12, 2026
  12. added
    status/in-review
    and removed
    status/ready
    on Nov 12, 2026
  13. removed
    status/in-review
    owner/agent
    on Nov 12, 2026
  14. devops-cli-service commented on Nov 12, 2026

    @devops-cli-service
    Contributor

    Live since 2026-11-12 21:56 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/lowpriority/p2-mediumsource/agenttype/refactorvalue/medium

    Type

    No type

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions