Skip to content

refactor(cleanup): remove dead workflow package and deps aggregator - #3644

Merged
Daniel Meppiel (danielmeppiel) merged 3 commits into
mainfrom
danielmeppiel-perf-single-prompt-walk-3524
Nov 12, 2026
Merged

Daniel Meppiel (danielmeppiel) merged 3 commits into
mainfrom
danielmeppiel-perf-single-prompt-walk-3524

Conversation

@danielmeppiel

@danielmeppiel Daniel Meppiel (danielmeppiel) commented Nov 12, 2026 •

Copy link
Copy Markdown
Collaborator

refactor(cleanup): remove dead workflow/ package and deps/aggregator.py

TL;DR

apm_cli.workflow (discovery, parser, runner) and apm_cli.deps.aggregator have no production callers on main — apm run goes through core/script_runner.py. This PR deletes them (closing the duplicated *.prompt.md glob walks reported in #3524 by removal rather than consolidation), plus their re-export, PyInstaller hidden imports, linter entry and the tests that only exercised them. No CLI command, flag or output changes.

Fixes #3524

Important

The approved scope record (#3524 comment) chose removal over the issue body's "one shared walk" proposal: "Close out this performance finding by removing code verified on origin/main to have no production callers, instead of consolidating globs". This PR implements the record. Local preflight skipped by maintainer instruction (2026-11-12); CI is the gate.

Description

Dead-code removal. 24 files, +64 / −2527.

Issue and approved scope

Issue: Fixes #3524

Human scope-approval comment: #3524 (comment) (approver and review contact Daniel Meppiel (@danielmeppiel); eligibility.cjs → record-present at trusted 1a370716e1).

Does this PR complete the issue? Yes — every Done-when clause is met (see Validation); CI proves the unit-suite clause.

Problem (WHY)

  • [!] discover_workflows() and scan_workflows_for_dependencies() each ran two recursive glob.glob walks where one pattern already covered the other, and the aggregator used list(set(...)) (nondeterministic order) — perf: single prompt.md walk in workflow discovery and dependency aggregator #3524.
  • Neither function, nor anything else in apm_cli.workflow / deps.aggregator, is reachable from a CLI command: git grep on main finds only self-references, the deps/__init__.py re-export, build/apm.spec hidden imports, one architecture-linter path, and tests.
  • [!] ~2,000 lines of tests kept that dead code "covered", costing CI time and reviewer attention.

Why it matters: optimizing an unreachable walk improves nothing for users; the record's Out-of-scope forbids "Changing glob patterns of any live code path", so deletion is the only in-scope fix.

Approach (WHAT)

# Change
1 Delete src/apm_cli/workflow/ (4 modules) and src/apm_cli/deps/aggregator.py.
2 Drop the scan_workflows_for_dependencies / sync_workflow_dependencies re-export from apm_cli.deps.
3 Drop matching hiddenimports from build/apm.spec and src/apm_cli/workflow/runner.py from _RUNTIME_NAME_CONSUMERS.
4 Delete tests that only exercised removed code; trim removed-code parts of mixed test files.
5 Add tests/unit/test_dead_workflow_code_removed.py regression guard.

Implementation (HOW)

  • src/apm_cli/workflow/*, src/apm_cli/deps/aggregator.py — deleted. core/script_runner.py (incl. the live PromptCompiler._substitute_parameters) is untouched.
  • src/apm_cli/deps/__init__.py — import and two __all__ entries removed.
  • build/apm.spec — five hiddenimports entries removed.
  • scripts/architecture_linter/checks/registry_owner_guards.py — removed path from _RUNTIME_NAME_CONSUMERS; docstring no longer says "four" modules.
  • Deleted tests — tests/unit/workflow/, tests/unit/deps/test_aggregator.py, tests/unit/test_workflow_runner_{branch_coverage,phase3w4}.py, tests/{basic_workflow_test,noninteractive_workflow_test,manual_workflow_script}.py, tests/integration/test_llm_runtime_integration.py.
  • Trimmed tests — tests/unit/test_deps.py (aggregator class), tests/integration/test_multi_runtime_integration.py (two run_workflow tests; RuntimeFactory test kept), tests/integration/test_runtime_smoke.py (test_apm_workflow_compilation), tests/integration/test_coverage_gaps_phase4w2.py (TestDepAggregator, TestWorkflowDiscovery).
  • Kept live coverage — the compute_file_hash() symlink test from the deleted tests/unit/workflow/test_workflow.py moves to tests/unit/test_content_hash.py (mutation-break: dropping or file_path.is_symlink() fails it). That file's PackageManagerFactory cases are already duplicated in tests/integration/test_wave2_adapters_coverage.py.
  • New guard — asserts each removed module has no importable source (tolerates a stale __pycache__ namespace dir), apm_cli.deps no longer exports the two names, and PromptCompiler._substitute_parameters stays live.

Diagrams

Legend: the only path from apm run to prompt files is script_runner; the removed modules (dashed) hung off nothing but a re-export and tests.

flowchart LR
    CLI["apm run"] --> SR["core/script_runner.py"]
    SR --> PC["PromptCompiler"]
    DI["deps/__init__.py re-export"] -.-> AG["deps/aggregator.py (removed)"]
    T["tests only"] -.-> WF["workflow/ package (removed)"]
    T -.-> AG
    WF -.-> PR["workflow/parser.py (removed)"]
Loading

Trade-offs

  • Remove vs consolidate the globs — the issue proposed a shared pruned walk; the approved record chose deletion because no live caller benefits. A future feature needing prompt discovery should use primitives/discovery.py.
  • Library API — apm_cli.deps.scan_workflows_for_dependencies / sync_workflow_dependencies disappear. APM is a CLI, not a documented library; no CLI surface changes.
  • Coverage drop — deleted tests covered only deleted code; no live module loses coverage.

Benefits

  1. −2,527 / +51 lines; five fewer modules in the frozen binary.
  2. The two redundant recursive walks from perf: single prompt.md walk in workflow discovery and dependency aggregator #3524 no longer exist anywhere in src/.
  3. 119 fewer test functions that exercised only dead code.
  4. A regression guard fails if any removed module or re-export returns.

Validation

$ git grep -nE "apm_cli\.workflow|deps\.aggregator|apm_cli/workflow|scan_workflows_for_dependencies|sync_workflow_dependencies|discover_workflows|create_workflow_template|find_workflow_by_name|preview_workflow|parse_workflow_file|WorkflowDefinition|collect_parameters|\brun_workflow\b|\bsubstitute_parameters\b" -- src build scripts
(no output, exit 1)
Targeted tests, mutation-break, lint mirror
# TDD red (before deletion)
$ pytest -p no:xdist -q tests/unit/test_dead_workflow_code_removed.py
8 failed                      # live-method check then pointed at the wrong class; fixed to PromptCompiler

# green after deletion
$ pytest -p no:xdist -q tests/unit/test_dead_workflow_code_removed.py tests/unit/test_deps.py tests/integration/test_coverage_gaps_phase4w2.py
105 passed
$ pytest -p no:xdist -q --collect-only tests/integration/test_multi_runtime_integration.py tests/integration/test_runtime_smoke.py
9 tests collected
$ pytest -p no:xdist -q tests/integration/test_architecture_owner_rule_mutations.py -k runtime
4 passed, 566 deselected

# mutation-break
restore src/apm_cli/workflow/runner.py           -> 1 failed, 7 passed
restore deps/aggregator.py + deps/__init__.py    -> 3 failed, 5 passed
revert mutations                                 -> 8 passed

# architecture linter
$ bash scripts/lint-architecture-boundaries.sh   -> exit 0

# CI lint mirror (ruff 0.15.12 = uv.lock pin)
ruff check            -> All checks passed
ruff format --check   -> clean
pylint R0801          -> 10.00/10
lint-auth-signals.sh  -> exit 0

Scenario evidence

Pure removal of unreachable code; no user-promise scenario changes. The live apm run prompt path stays covered by existing script_runner tests; the guard asserts PromptCompiler._substitute_parameters is still present.

Type of change

  • Bug fix
  • New feature
  • Documentation
  • Maintenance / refactor

Testing

  • Tested locally (targeted files only, per maintainer instruction; CI runs the full suite)
  • All existing tests pass (CI is the gate)
  • Added tests for new functionality (if applicable)

Spec conformance (OpenAPM v0.1)

  • Spec edit
  • Manifest edit
  • Test edit
  • CONFORMANCE.{md,json} regenerated
  • N/A -- this PR does not change OpenAPM-observable behaviour.

How to test

  • git grep -n "apm_cli.workflow\|deps.aggregator" -- src build scripts returns nothing.
  • uv run --extra dev pytest -q tests/unit/test_dead_workflow_code_removed.py passes.
  • apm run <script> with a .prompt.md behaves as before (path untouched).

Co-authored-by: Copilot [email protected]

apm_cli.workflow (discovery, parser, runner) and apm_cli.deps.aggregator
had no production callers on main; apm run goes through
core/script_runner.py. Remove them, the deps re-export, the PyInstaller
hiddenimports and the architecture-linter consumer entry, plus tests
that only exercised the removed code. Add a regression guard that the
modules stay gone.

Co-authored-by: Copilot App <[email protected]>
Copilot AI balanced review requested due to automatic review settings November 12, 2026 17:02

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

Deleting the workflow test module removes regression coverage for the still-active compute_file_hash() symlink rejection branch; the test must be moved to tests/unit/test_content_hash.py to preserve that coverage.

No open issues 🎉

What changed in this PR

Removes APM's unused workflow package and dependency aggregator, addressing #3524 through deletion rather than optimizing unreachable code. The live apm run implementation remains unchanged.

Changes:

  • Deletes legacy workflow modules, dependency aggregation, and associated exports.
  • Removes obsolete packaging and architecture-linter references.
  • Removes related tests, adds removal regression guards, and records the cleanup in the changelog.
File Description
tests/​unit/​workflow/​test_workflow.py Deletes the workflow test module.
tests/​unit/​workflow/​__init__.py Removes the test package initializer.
tests/​unit/​test_workflow_runner_phase3w4.py Deletes legacy runner coverage tests.
tests/​unit/​test_workflow_runner_branch_coverage.py Deletes legacy runner branch tests.
tests/​unit/​test_deps.py Removes aggregator tests; retains verifier tests.
tests/​unit/​test_dead_workflow_code_removed.py Adds guards against restoring removed modules and exports.
tests/​unit/​deps/​test_aggregator.py Deletes aggregator-specific tests.
tests/​noninteractive_workflow_test.py Removes the noninteractive workflow script.
tests/​manual_workflow_script.py Removes the manual workflow script.
tests/​integration/​test_runtime_smoke.py Removes legacy workflow preview coverage.
tests/​integration/​test_multi_runtime_integration.py Removes workflow tests; retains runtime factory coverage.
tests/​integration/​test_llm_runtime_integration.py Deletes workflow/runtime integration tests.
tests/​integration/​test_coverage_gaps_phase4w2.py Removes aggregator and workflow discovery cases.
tests/​basic_workflow_test.py Deletes basic workflow tests.
src/​apm_cli/​workflow/​runner.py Deletes legacy execution and preview helpers.
src/​apm_cli/​workflow/​parser.py Deletes workflow parsing and definitions.
src/​apm_cli/​workflow/​discovery.py Deletes discovery and template generation.
src/​apm_cli/​workflow/​__init__.py Removes the workflow package initializer.
src/​apm_cli/​deps/​aggregator.py Deletes workflow dependency aggregation.
src/​apm_cli/​deps/​__init__.py Removes aggregator imports and exports.
scripts/​architecture_linter/​checks/​registry_owner_guards.py Removes the deleted runner from runtime consumers.
CHANGELOG.md Records the internal code removal.
build/​apm.spec Removes hidden imports for deleted modules.

Review effort: Balanced

The deleted tests/unit/workflow/test_workflow.py also held a test for
the live compute_file_hash() symlink branch. Move it next to the other
compute_file_hash tests so that coverage survives the dead-code removal.
PackageManagerFactory cases from the same file are already covered in
tests/integration/test_wave2_adapters_coverage.py.

Addresses Copilot review on PR #3644.

Co-authored-by: Copilot App <[email protected]>
@danielmeppiel

Copy link
Copy Markdown
Collaborator Author

APM Review Panel: ship_now

Dead-code removal (-2527 lines) now recovers both live-code test gaps flagged by Copilot review; CI green, no coverage regressions.

panel-mode=lean then delta; personas=python-architect,test-coverage-expert,apm-ceo

cc Sergio Sisternes (@sergio-sisternes-epam) -- a fresh advisory pass is ready for your review.

The prior lean pass at 4088785 returned zero findings from both python-architect and test-coverage-expert. The only material signal since then was a legitimate Copilot review observation: the deleted tests/unit/workflow/test_workflow.py also housed tests for live code -- the compute_file_hash() symlink branch and PackageManagerFactory construction. Commit ef6dec8 relocates the symlink regression trap to tests/unit/test_content_hash.py with mutation-break proof; the PackageManagerFactory cases were already duplicated in tests/integration/test_wave2_adapters_coverage.py.

The delta test-coverage pass confirms both gaps are recovered with no coverage regressions. CI is fully green at the new head; lint mirror and architecture boundary lint are clean; the owner-touch gate reports no canonical owner touched. This is a 2527-line dead-code removal that closes #3524 without touching any user-facing surface.

Aligned with: Pragmatic as npm -- removing dead code keeps the codebase lean and the dependency surface minimal. OSS community driven -- a smaller surface lowers the barrier for new contributors.

Panel summary

Persona B R N Takeaway
Python Architect 0 0 0 Clean dead-code removal with thorough regression guard; no architectural concerns.
Test Coverage Expert 0 0 0 Delta recovers both live-code test gaps flagged by review: symlink regression trap added with mutation-break proof, PackageManagerFactory already duplicated in wave2. No coverage regressions.

B = blocking-severity findings, R = recommended, N = nits.
Counts are signal strength, not gates. The maintainer ships.

Recommendation

The delta pass confirms the prior ship_now stance. Both live-code test gaps surfaced by Copilot review are recovered with mutation-break proof, CI is green, and no panelist raised a finding across either pass. No follow-ups to track.

  • Folded in this run: keep compute_file_hash symlink coverage in tests/unit/test_content_hash.py (ef6dec8).
  • Copilot signals reviewed: 1 -- LEGIT (symlink test lost with the deleted module; folded). The PackageManagerFactory half was already covered.
  • Deferred: none.
  • Lint: ruff check/format (0.15.12), pylint R0801, lint-auth-signals, lint-architecture-boundaries all clean.
  • CI: 22 pass, 2 skipping at ef6dec8; license/cla success.
PR Head Stance Iter Folds Deferrals Copilot rounds CI Mergeable State Notes
#3644 ef6dec8 ship_now 1 1 0 1 green MERGEABLE BLOCKED pending required review

Full per-persona findings

Python Architect

No findings.

Test Coverage Expert

No findings.

This panel is advisory. It does not block merge. Re-apply the
panel-review label after addressing feedback to re-run.


Generated by autopilot-pr-review-worker. This comment is AI-generated and may contain errors.

@danielmeppiel
Daniel Meppiel (danielmeppiel) merged commit daff754 into main Nov 12, 2026
26 checks passed
@danielmeppiel
Daniel Meppiel (danielmeppiel) deleted the danielmeppiel-perf-single-prompt-walk-3524 branch November 12, 2026 18:07
Daniel Meppiel (danielmeppiel) added a commit that referenced this pull request Nov 12, 2026
Clean merge of #3644 and #2030; no lockfile or autopilot package
changes.

Co-authored-by: sergio-sisternes-epam <[email protected]>
Co-authored-by: Copilot App <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

perf: single prompt.md walk in workflow discovery and dependency aggregator

2 participants