Skip to content

refactor(security): delete the dependency-manifest parsers, transit helpers and orphan core modules nothing calls #1841

Closed

Description

@dan-petty

All symbols have no src caller (ranker grep found only definitions and export maps), the last caller of extract_dependencies_from_text was removed in v0.2.38 (#1799), and nothing here shares files with the other first-wave items.

Existing tool considered: Nothing: osv-scanner (security/osv_scanner.py) and trivy already scan lockfiles, and run_subprocess in core/process.py and typer's own exit handling serve every caller. The code to delete is about 760 lines of source and tests (audit of 2026-10-22, spot-checked by the ranker and re-checked by an adversarial verifier). Keeping it means carrying it through every gate run, every refactor and every review, and fixing the defects it produces, for no caller.

Evidence (verifier, 2026-10-22):

  • Deadness verified. git grep over src and tests finds only definitions, export maps and their own tests for extract_dependencies_from_text and its five extractors, transit_encrypt, transit_decrypt, CallableProvider, ProcessExecutionPipeline, ProcessExecutionResult and cli_command_handler. No @cli_command_handler decorator use exists. The last extract_dependencies_from_text caller was removed in 1a8b26c (v0.2.38), where pipeline.py dropped its import and both call sites. Dashboards and docs use main.py's devops_cli_command_total and devops_cli_command_duration_seconds, not cli.command.* or subprocess.execution.duration_seconds. run_subprocess already handles TRACEPARENT. No symbol becomes newly orphaned except two Vault path constants (correction 3).
  • Experiment in /tmp/open-libs-audit/verify-R09/: I applied the whole deletion to a git-archive copy with corrections 1-8. ruff check and format pass on src and tests. mypy on the touched src files is clean; its one error, at tests/test_secret_resolution.py:411, is in unchanged code, and the gate type-checks src only. The 283 tests in the touched and invariant files pass, including test_public_export_surface, test_architectural_invariants (C901 ceiling), test_codebase_hygiene_and_shims and test_agent_invariants. The full suite gives 11379 passed and 9 failed. Seven of the 9 pass once the copy is a git repo; the other two (test_roadmap_reprioritize telemetry gauges and test_host_sandbox) also fail on the unmodified archive, so none are caused by the change. The deletion only removes code and tests, so it cannot slow the gate or the hooks. It touches no pyproject.toml or uv.lock entry: packaging is still used by kb.py, pr.py, roadmap/store.py and others.
  • The ratchet fixture edit is mandatory. With secrets.py left at 4, tests/test_swallowed_failures_ratchet.py fails with {'src/devops_cli/security/secrets.py': (3, 4)}, because CallableProvider carried one swallowed except Exception. No other deleted file is in that fixture.

Proposed change: Delete security/reference_extractor.py lines 751-946 (the pip, pyproject, package.json, Cargo and go.mod extractors and extract_dependencies_from_text, with the packaging.requirements import); security/vault_lease.py transit_encrypt and transit_decrypt (47 lines); security/secrets.py CallableProvider (19 lines); core/process_pipeline.py (143) and core/command_decorator.py (111); their export-map entries in security/init.py and core/init.py. Leave validate_session_id and validate_file for the next PR (tests/test_validation.py is edited by R01). Leave the review pipeline's now-empty file_deps chain alone (#771).

Corrections found by the verifier (the change includes them):

    1. tests/test_reference_extractor.py: the dependency tests are not only lines 179-226. Seven functions use the deleted code, 182 lines in total, at 179-228 (three tests), 456-497 (test_extract_dependencies_pep621_and_extras), 744-763 (test_extract_dependencies_various_ecosystems), 890-930 (test_dependency_extractors_cargo_go_and_package_assets) and 933-965 (test_extract_package_json_and_manifest_dispatch). Also drop the extract_dependencies_from_text import. Leave test_dependency_and_network_reference_canonical_location_formatting; it only builds DependencySpec from models.
    1. tests/test_secret_resolution.py: the remaining tests do NOT all pass unchanged. test_providers_satisfy_the_protocol builds CallableProvider('tool', lambda ref: None) in its provider tuple, so remove that entry and keep the test. Delete test_callable_provider_wraps_bespoke_lookups, the whole 'Transit envelope encryption' section (three tests, about 40 lines) and the CallableProvider, transit_encrypt and transit_decrypt imports. Reword the acceptance bullet to 'the other tests in both files pass; the only edit to a surviving test is the one tuple entry'.
    1. Add src/devops_cli/config/constants.py to files_owned and delete CONST_VAULT_PATH_TRANSIT_ENCRYPT and CONST_VAULT_PATH_TRANSIT_DECRYPT (lines 2317-2318), which are orphaned once vault_lease.py stops importing them; also drop the two imports in vault_lease.py. R01 edits constants.py too (CONST_DOMAIN_EXCEPTION_MODULES near line 122 and harness constants), but the lines are far apart.
    1. The VaultLeaseError docstring at src/devops_cli/exceptions/vault.py:118 says 'lease, login, token or Transit call fails' and feeds docs/ERRORS.md line 150 (generated by docs generate). Remove 'or Transit' and regenerate. Add exceptions/vault.py to files_owned, and note R01 also owns docs/ERRORS.md (different rows; whichever merges second regenerates).
    1. reference_extractor.py: besides deleting lines 751-946, remove the Requirement/InvalidRequirement import and DependencySpec from the models import (otherwise ruff F401), the extract_dependencies_from_text entry in all, and fix the module docstring line 1 ('Extractors for software dependencies (manifests) and network references'). json, tomllib, Path and logger stay in use.
    1. Export maps: security/init.py holds entries only for extract_dependencies_from_text, in three places (TYPE_CHECKING import at line 25, lazy map at lines 83-86, all at line 174). CallableProvider and the transit helpers are not exported there. core/init.py needs three map entries and three all entries removed (cli_command_handler, ProcessExecutionPipeline, ProcessExecutionResult).
    1. tests/fixtures/swallowed_failures_ceilings.json: set security/secrets.py to 3 (verified required); use uv run python -m tests.test_swallowed_failures_ratchet --lower rather than hand-editing.
    1. Optional, since the owner rule is to fix docs a change makes stale: src/devops_cli/ai/knowledge_base/devops_cli/tasks/ai_code_review.md:25 says the static scan does 'dependency extraction with OSV advisories'. It describes the pipeline that feat(release): v0.2.38 #1799 already changed to offline osv-scanner over lockfiles; reword it to the lockfile scan. No other first-wave item owns that file.
    1. Correct deletes_loc to about 995 (src 551 plus tests about 450, minus 2 added) and state the replacement as 'none: zero callers (dead since feat(release): v0.2.38 #1799)' instead of naming osv-scanner and trivy as equivalents.
    1. The delivering PR also carries the usual changelog.d/.md fragment and task file. Leave docs/agent/tasks/task-311 and task-709, which describe delivered history, and docs/SELF_IMPROVEMENT.md lines 310 and 341, which cite older sessions.

Acceptance criteria:

  • extract_dependencies_from_text and its five extractors, transit_encrypt, transit_decrypt, CallableProvider, ProcessExecutionPipeline and cli_command_handler are deleted with every test that exists only for them; a grep of src and tests for those names returns nothing.
  • security/init.py and core/init.py export maps list no deleted name, and tests/test_public_export_surface.py passes.
  • The network-reference tests in tests/test_reference_extractor.py and the remaining tests in tests/test_secret_resolution.py pass unchanged.
  • uv run devops ci passes in full.

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 deleting unused code, which is a refactor.
    • Priority: P2-Medium. This is a cleanup of dead code that improves maintainability but does not address an urgent issue.
    • Value: Medium. Removing dead code improves clarity and reduces risk, but the impact to users is limited.
    • Effort: Low. The deletion is well-scoped and verified with automated checks, indicating low implementation effort.
  3. added this to the v0.2.39 milestone on Oct 22, 2026
  4. added
    status/in-progress
    on Oct 22, 2026
  5. added a commit that references this issue on Oct 22, 2026
    b0fdd8d
  6. dan-petty commented on Oct 22, 2026

    @dan-petty
    OwnerAuthor

    What changed

    #1850, merged into release/v0.2.39 as b0fdd8d.

    Cause: five groups of code had no caller and were still carried through every gate run, refactor and review. They are the pip, pyproject, package.json, Cargo and go.mod manifest parsers with extract_dependencies_from_text (its last caller left pipeline.py in v0.2.38, #1799, when the review began scanning lockfiles with osv-scanner), the Vault Transit helpers transit_encrypt and transit_decrypt, CallableProvider, and the core modules process_pipeline.py (ProcessExecutionPipeline) and command_decorator.py (cli_command_handler). git grep over the whole repository at release/v0.2.39 (5b72063) finds, in src, tests, k8s and .github, only their definitions, export maps and the tests written for them. In documents it finds docs/SELF_IMPROVEMENT.md, whose two calibration rows naming cli_command_handler and command_decorator.py:93 are corrected here, and records of what was delivered or released then, which stay as written: CHANGELOG.md, docs/agent/archive/historical-phases-1-to-50.md and the delivered task files task-205, 311, 709, 718, 921 and 952. No @cli_command_handler decorator is applied anywhere, and the metrics they recorded (cli.command.*, subprocess.execution.duration_seconds) appear in no dashboard or document.

    Change: the code above is deleted, with the export-map entries in security/init.py and core/init.py and the Requirement and DependencySpec imports and the all entry in reference_extractor.py. Everything that only the deleted code made true goes with…

    20 file(s) changed.

    How it was verified

    Check runs at 293caf8:

    • Prune PR DevContainer Images: pass
    • Audit Defect PR Hardening: skipping
    • zizmor: pass
    • devops-cli: pass
    • bandit: pass
    • CodeQL: pass
    • Tests & Coverage: pass
    • Fail-to-Pass Self-Check: pass
    • Rule Pack Tests: pass
    • Changed-Test Independence: pass
    • Analyze (python): pass
    • Fail-to-Pass Check: pass
    • Analyze (actions): pass
    • Static Analysis: pass
    • Service Image: skipping
    • Dependency Freshness: skipping
    • DevContainer Image: skipping

    Acceptance Criteria of docs/agent/tasks/task-1841-orphan-parsers-and-helpers.md:

    • extract_dependencies_from_text and its five extractors, transit_encrypt, transit_decrypt, CallableProvider, ProcessExecutionPipeline, ProcessExecutionResult and cli_command_handler are deleted with every test that existed only for them; a git grep of src and tests for those names returns nothing.
    • security/__init__.py and core/__init__.py list no deleted name, and tests/test_public_export_surface.py passes.
    • The other tests in tests/test_reference_extractor.py and tests/test_secret_resolution.py pass; the only edit to a surviving test is the one tuple entry in test_providers_satisfy_the_protocol.
    • The constants, the exception docstring and the generated docs/ERRORS.md row, the ratchet ceiling and the knowledge-base line that only the deleted code made true are removed or corrected.
  7. added a commit that references this issue on Oct 23, 2026
    f209f6c
  8. removed
    status/in-progress
    on Oct 30, 2026
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

    source/agenttype/refactor

    Type

    No type

    Projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions