Skip to content

Strangler Stage 1: tame the worst outliers #1077

Closed

Description

Strangler Stage 1: tame the worst outliers

Labels: good first issue, code-quality, refactor


Stage 1 -- tame the worst outliers

Tighten Ruff thresholds from baseline to Stage 1 targets. This stage focuses on the small number of extreme outliers that gate every metric.

Threshold changes

Metric Current Stage 1 Violations Files
max-statements 275 200 1 1
max-branches 115 60 1 1
max-complexity 100 50 2 2
max-args 18 15 5 4
max-returns 18 12 4 4
file-length 2400 1400 3 3

Key files to refactor

mcp_integrator.py::install (owns 3 metrics simultaneously):

  • 269 statements (target: 200)
  • 108 branches (target: 60)
  • 97 complexity (target: 50)
  • Extract phases into private helpers (_validate, _resolve, _deploy, _hooks)

install/validation.py (complexity 65, target 50)

commands/install.py (18 args on two functions, target 15):

  • Reduce via parameter objects or context dataclasses

marketplace/publisher.py (16 returns, target 12):

  • Early-return consolidation

File length (3 files > 1400 lines):

  • github_downloader.py (2316), commands/install.py (1680), skill_integrator.py (1365)

How to verify

# Update thresholds in pyproject.toml, then:
uv run ruff check src/ tests/

# Update MAX_LINES in .github/workflows/ci.yml, then check:
find src/ -name '*.py' | xargs wc -l | awk '$1 > 1400'

References

Activity

  1. added
    good first issue
    refactor
    code-quality
    on Apr 30, 2026
  2. zeel2104 commented on Apr 30, 2026

    @zeel2104
    Contributor

    Open for contribution?

  3. added
    status/needs-triage
    on May 1, 2026
  4. sergio-sisternes-epam commented on May 1, 2026

    @sergio-sisternes-epam
    ContributorAuthor

    Absolutely Zeel Desai (@zeel2104), go for it!

  5. github-actions commented on May 1, 2026

    @github-actions

    Triage decision

    accept

    Proposed labels

    area/cli
    area/ci-cd
    type/refactor
    status/accepted
    priority/low
    good first issue
    

    Milestone

    null -- no open milestones found in the repository at triage time.

    Suggested next action

    Pick one file from the key-files list (start with marketplace/publisher.py early-return consolidation or install/validation.py complexity reduction), open a focused PR against parent #1076, and verify with uv run ruff check src/ tests/ before pushing.

    Suggested issue comment

    Thanks for the structured breakdown -- the metric table and per-file
    targets make this straightforward to pick up incrementally.
    
    The panel accepts this as written. A few notes for the implementer:
    
    - When extracting `_validate`, `_resolve`, `_deploy`, `_hooks` from
      `mcp_integrator.py::install`, preserve the operation ordering:
      identity/integrity checks (validate/resolve) must complete before
      any file writes (deploy). All path joins must continue flowing
      through `path_security.validate_path_segments` / `ensure_path_within`.
    - For `commands/install.py` arg reduction, a frozen dataclass is the
      idiomatic APM pattern (see `DiagnosticCollector` and the
      BaseIntegrator family). Name the dataclass after the phase it
      represents (e.g. `InstallContext`) and keep it in the same file
      until a second call site warrants moving it to `core/`.
    - The Ruff threshold edits in `pyproject.toml` and the `MAX_LINES`
      guard in `.github/workflows/ci.yml` should land in the same commit
      as the refactor they gate -- not ahead of it.
    
    Two existing labels (`refactor`, `code-quality`) are not in the APM
    label taxonomy. The panel has proposed `type/refactor` (canonical) in
    their place; a maintainer can remove the non-taxonomy labels if they
    choose.
    
    Good first issue: the `marketplace/publisher.py` early-return
    consolidation (16 -> 12 returns) or `install/validation.py` complexity
    reduction (65 -> 50) are the lowest-risk entry points. Either can
    land as a standalone PR referencing this issue.

    Per-lens notes (collapsed)

    DevX UX Expert -- User-Need Reviewer

    Pure internal code quality refactor with no user-facing surface change. The decomposition of mcp_integrator.py::install into phase helpers improves long-term maintainability and will make error paths easier to follow, which indirectly benefits UX. Issue is well-scoped with concrete verification steps (uv run ruff check + find ... wc -l). No discoverability, familiarity, or composability concerns flagged.

    Supply Chain Security Expert -- Risk-Surface Reviewer

    No direct P/G/S risk surface implication. The refactoring of mcp_integrator.py::install is the only security-adjacent touch -- it is the critical install-path function. The implementer must ensure that helper extraction preserves the semantic ordering (validate/resolve before deploy/hooks) and that all file operations continue to route through path_security.validate_path_segments / ensure_path_within. No lockfile schema change, no registry interaction change, no auth flow change. Implementation-time reminder only; not a reason to withhold acceptance.

    OSS Growth Hacker -- Contributor-Tone Reviewer

    Not activated -- author is a project COLLABORATOR (sergio-sisternes-epam), not a new or low-interaction contributor; tone tuning for first-time contributors is not warranted.

    Python Architect -- Architecture Reviewer

    The refactoring scope is well-specified and feasible. Phase-extraction from install() (_validate/_resolve/_deploy/_hooks) aligns with APM's existing lifecycle patterns (CommandLogger, BaseIntegrator). Parameter reduction via frozen dataclass is consistent with APM's dataclass guidance. Ruff threshold changes are mechanical CI config edits. Parent issue #1076 confirms this is part of a coordinated strangler fig plan, not an isolated change. No cross-cutting design decision (new interface, data model, migration boundary, or primitive) is required before code can land -- status/accepted is correct and status/needs-design is not warranted.

    Doc Writer -- Documentation Reviewer

    Not activated -- this is a pure internal code quality refactor with no user-facing CLI surface change, no new commands, no new flags, and no new authoring concepts. No documentation updates to docs/src/content/docs/ or the README are implied by this issue.

    APM CEO -- Triage Arbiter

    Straightforward accept. This is a planned, well-scoped code quality refactor under the strangler fig strategy (#1076). No product surface is touched, no theme mega-label is required (pure area/cli + area/ci-cd scope with no P/G/S implication). The good-first-issue label is warranted and preserved -- the issue names exactly which files and metrics to target, which gives a contributor a clear entry point. No open milestones exist at triage time; this rolls into whichever patch cycle the maintainer targets. All specialists agreed; no arbitration dispute.

    {
      "decision": "accept",
      "decision_detail": "",
      "theme": null,
      "areas": ["area/cli", "area/ci-cd"],
      "type": "type/refactor",
      "status": "status/accepted",
      "priority": "priority/low",
      "preserved_labels": ["good first issue"],
      "milestone": null,
      "next_action": "Pick one file from the key-files list (start with marketplace/publisher.py or install/validation.py), open a focused PR against parent #1076, and verify with uv run ruff check src/ tests/ before pushing.",
      "comment_markdown": "Thanks for the structured breakdown -- the metric table and per-file targets make this straightforward to pick up incrementally.\n\nThe panel accepts this as written. A few notes for the implementer:\n\n- When extracting _validate, _resolve, _deploy, _hooks from mcp_integrator.py::install, preserve the operation ordering: identity/integrity checks (validate/resolve) must complete before any file writes (deploy). All path joins must continue flowing through path_security.validate_path_segments / ensure_path_within.\n- For commands/install.py arg reduction, a frozen dataclass is the idiomatic APM pattern (see DiagnosticCollector and the BaseIntegrator family). Name the dataclass after the phase it represents (e.g. InstallContext) and keep it in the same file until a second call site warrants moving it to core/.\n- The Ruff threshold edits in pyproject.toml and the MAX_LINES guard in .github/workflows/ci.yml should land in the same commit as the refactor they gate -- not ahead of it.\n\nTwo existing labels (refactor, code-quality) are not in the APM label taxonomy. The panel has proposed type/refactor (canonical) in their place; a maintainer can remove the non-taxonomy labels if they choose.\n\nGood first issue: the marketplace/publisher.py early-return consolidation (16 -> 12 returns) or install/validation.py complexity reduction (65 -> 50) are the lowest-risk entry points. Either can land as a standalone PR referencing this issue."
    }

    Triage status: agentic proposal pending human ratification.
    Silence is approval. Maintainers can:

    • Override any label or milestone above by editing it directly --
      human edits are authoritative and will not be reverted on
      subsequent runs.
    • Re-trigger triage by applying the status/needs-triage label, or
      by removing status/triaged to enroll the issue in the next
      daily sweep.

    Posted by the Triage Panel workflow. See .apm/skills/apm-triage-panel for the panel skill.

    Generated by Triage Panel for issue #1077 · ● 372.4K · ◷

  6. added
    area/ci-cd
    area/cli
    priority/low
    status/accepted
    status/triaged
    type/refactor
    and removed
    status/needs-triage
    on May 1, 2026
  7. moved this from Todo to In Progress in APM Roadmapon May 3, 2026
  8. moved this from In Progress to Done in APM Roadmapon Jun 3, 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

    area/ci-cdarea/clicode-qualitygood first issuepriority/lowrefactorstatus/acceptedstatus/triagedtype/refactor

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions