Skip to content

Cowork internal refactors — DRY and hot-path cleanup #922

Closed

Description

Follow-up to #913. Surfaced by the APM Expert Review Panel (Python Architect specialist). All MEDIUM-severity maintenance items, no user-facing impact. CEO arbitration: acceptable as follow-ups, no release gate.

1. SkillIntegrator inlines dynamic-root routing 3x

File: src/apm_cli/integration/skill_integrator.py:666-667, 778-779, 838-839

Three call sites open-code if target.resolved_deploy_root is not None: ... instead of calling the target.deploy_path() accessor the PR itself introduced. This re-duplicates the very abstraction the target profile is meant to provide.

Fix: route all three sites through target.deploy_path(...).

2. resolve_cowork_skills_dir() called twice per entry in sync_remove_files

File: src/apm_cli/integration/base_integrator.py around lines 410 and 420

Each call hits apm config read + OneDrive glob. In a sync loop this compounds.

Fix: resolve once at the top of the cowork branch in sync_remove_files, reuse the value.

3. unset_temp_dir() / unset_cowork_skills_dir() copy-paste bypassing update_config()

File: src/apm_cli/config.py:129-140, 178-189

Two near-identical unset helpers, both re-implementing the read-modify-write pattern instead of calling update_config(). Maintenance trap for any future config-file format change.

Fix: consolidate into _unset_key(key) that calls update_config(); keep the two public wrappers as one-liners.


Acceptance criteria

  • All three SkillIntegrator sites call target.deploy_path(...).
  • sync_remove_files resolves the cowork root once per sync invocation.
  • Both unset helpers delegate to a single implementation that uses update_config().
  • Existing tests remain green; add a regression test for the update_config code path in both unset helpers.

/cc panel review: #913

Activity

  1. added
    enhancement
    area/multi-target
    on Apr 24, 2026
  2. changed the title [-]Cowork internal refactors — DRY and hot-path cleanup[/-] [+]VOID[/+] on Apr 24, 2026
  3. removed
    enhancement
    area/multi-target
    on Apr 24, 2026
  4. changed the title [-]VOID[/-] [+]Cowork internal refactors — DRY and hot-path cleanup[/+] on Apr 25, 2026
  5. added
    enhancement
    area/multi-target
    on Apr 25, 2026
  6. 3 remaining items

  7. added
    type/refactor
    status/accepted
    enhancement
    and removed
    type/refactor
    status/accepted
    on Apr 25, 2026
  8. github-actions commented on Apr 27, 2026

    @github-actions

    Triage decision

    accept

    Proposed labels

    area/multi-target
    area/cli
    type/refactor
    status/accepted
    

    Milestone

    null

    Suggested next action

    Open a PR touching skill_integrator.py, base_integrator.py, and config.py to address all three items in one atomic changeset per the acceptance criteria.

    Suggested issue comment

    Thanks for filing these follow-ups cleanly -- three distinct, well-scoped code-quality items with acceptance criteria attached.
    
    Triage summary:
    
    - **DX impact**: none visible to end users; all changes are internal plumbing under the `cowork` experimental flag.
    - **Security**: no risk surface touched -- the refactors go through existing safe abstractions (`target.deploy_path()`, `update_config()`).
    - **Architecture**: straightforward DRY fixes. No design decision needed. A single PR touching `skill_integrator.py`, `base_integrator.py`, and `config.py` is the right delivery shape.
    
    Decision: **accept**. These are non-blocking maintenance follow-ups to #913. They may land at any point while cowork is behind the experimental flag; they are not on the GA exit-criteria critical path (that is #925).
    
    Next step: open a PR with all three fixes and add regression tests for the `update_config` code path in both unset helpers (per the acceptance criteria).

    Per-lens notes (collapsed)

    DevX UX Expert -- User-Need Reviewer

    No user-facing surface change. All three items are internal code-quality improvements under the experimental cowork flag. Zero impact on CLI commands, flags, output, or error messages. Acceptance criteria explicitly confirms "no user-facing impact."

    Supply Chain Security Expert -- Risk-Surface Reviewer

    No risk-surface implication. The refactors route through existing safe abstractions: target.deploy_path() (validated path accessor), update_config() (controlled config write). No lockfile, auth, marketplace, or MCP trust surface is touched.

    OSS Growth Hacker -- Contributor-Tone Reviewer

    Not activated -- sergio-sisternes-epam is a known collaborator with multiple prior contributions to microsoft/apm; no first-time-contributor tone tuning needed.

    Python Architect -- Architecture Reviewer

    All three items are correctly identified DRY violations. Item 1 (routing through target.deploy_path()) removes open-coded conditional chains; item 2 (caching resolve_cowork_skills_dir()) eliminates O(N) compound config reads in a sync loop; item 3 (consolidating unset helpers) prevents future config-format maintenance traps. No cross-module design decision required -- all fixes are contained within the three named files. Recommend landing as a single PR for atomic review.

    Doc Writer -- Documentation Reviewer

    Not activated -- pure internal refactor with no new CLI surface, no new config key, and no user-visible behavior change. No documentation update required for this changeset.

    APM CEO -- Triage Arbiter

    Clean accept. These three maintenance items are the textbook follow-up shape: specific, bounded, non-blocking, with clear acceptance criteria. They sit in the "recommended but non-blocking" bucket of the cowork GA exit criteria in #933. Land them when convenient; no milestone pressure until #925 clears the security gate.


    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 · ● 1.8M · ◷

  9. added
    area/cli
    status/accepted
    status/triaged
    type/refactor
    on Apr 27, 2026
  10. moved this from Done to In Progress in APM Roadmapon Jun 4, 2026
  11. danielmeppiel commented on Jun 25, 2026

    @danielmeppiel
    Collaborator

    Accepted -- scoped to item 1 only (the bounded DRY / hot-path cleanup in the cowork internal path). The broader refactor items that drifted onto this issue are out of scope for this acceptance; if they still matter, please split them into their own issues so each carries its own design and test surface.

    Constraint for the implementer: this is a behavior-preserving refactor. It must ship with the existing test suite green and no public CLI/manifest surface change -- a pure internal tidy. Anything that changes observable behavior gets kicked back to a feature issue.

  12. moved this from In Progress to Done in APM Roadmapon Jun 25, 2026
  13. added a commit that references this issue on Jun 25, 2026
    e3fa4dd
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/cliarea/multi-targetenhancementexperimentalstatus/acceptedstatus/triagedtype/refactor

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions