Skip to content

[code-simplifier] Split ApplyEngine.cs into focused modules #11730

Closed as not planned

Description

@github-actions

Code Simplification - 2026-10-03

This PR simplifies ApplyEngine.cs in the unskip-closed-tests-tool, splitting the 768-line monolithic file into focused partial class ApplyEngine modules, consistent with the pattern already used for InventoryEngine.

Files Simplified

  • .github/workflows/unskip-closed-tests-tool/ApplyEngine.cs (768 → 229 lines) — trimmed to the top-level ApplyAsync orchestration method plus the shared SourceEdit/VerificationOutcome records.

New Files

  • ApplyEngine.AgentSelection.cs (143 lines) — parses and validates the agent's selected candidate IDs (ReadAgentSelection, RequiredString).
  • ApplyEngine.Edits.cs (113 lines) — Roslyn-based computation of source-text edits (CreateEdit, RejectOverlappingEdits, ApplyTextEdit, DecodeUtf8).
  • ApplyEngine.Verification.cs (139 lines) — per-candidate test verification (VerifyCandidateAsync, CreateVerificationStartInfo, restricted env var list).
  • ApplyEngine.FileIO.cs (87 lines) — safe snapshot/write/restore operations on the working tree (ReadBytes, WriteBytes, RestoreFiles, ResetDirectory, TryDeleteDirectory, RestoreUnexpectedSourceMutations).
  • ApplyEngine.Results.cs (81 lines) — builds the ApplyResult/ChangedFileResult/RevertedCandidateResult DTOs (CreateChangedFiles, CreatePrTitle, CreatePrBody, CreateRevertedCandidate, EmptyResult).

Improvements Made

  1. Reduced Complexity — each file now has a single, clearly named responsibility; every file is under 300 lines (down from one 768-line file).
  2. Enhanced Clarity — related logic (edit computation, verification, file I/O, result shaping, agent-selection parsing) is grouped together, making it easier to navigate and review in isolation.
  3. Applied Project Standards — matches the existing partial class convention already used for InventoryEngine in the same tool, preserves the required UTF-8 BOM on all .cs files, and keeps the class internal static with identical public/internal surface.

No Functional Changes

This is a pure code-movement refactor:

  • Method bodies, signatures, and logic are unchanged.
  • No public API surface changed (class remains internal static, only split into partial files).
  • All using directives were trimmed to only what each partial actually needs.

Testing

  • ✅ dotnet build UnskipClosedTests.Tool.csproj succeeds with 0 warnings/errors.
  • ✅ The tool's own test suite (.github/workflows/unskip-closed-tests-tool/Tests) passes all 5 tests:
    • rejects malformed issue reference suffixes
    • removes GitHub credentials from verification
    • records exact final content hashes
    • keeps duplicate detection marker in titles
    • verifies every target-specific TRX
  • No functional changes — behavior is identical to before the split.

Review Focus

Please verify:

  • Each partial file groups the intended responsibility.
  • No behavior or public surface changed.
  • File sizes and naming align with the original split proposal in the tracked issue.

Warning

Protected Files — Push Permission Denied

This was originally intended as a pull request, but the change modifies protected files. A human must create the pull request manually.

Protected files

The push was rejected because GitHub Actions does not have workflows permission to push these changes, and is never allowed to make such changes, or other authorization being used does not have this permission.

Create the pull request manually
# Download the artifact from the workflow run
gh run download '37130091279' -n agent -D '/tmp/agent-37130091279'

# Resolve the bundle source ref, fetch it into a temporary ref, then create the local branch
bundle_path='/tmp/agent-37130091279/aw-code-simplifier-split-applyengine.bundle'
temp_ref='refs/bundles/create-pr-code-simplifier-split-applyengine-69b2587cda46228e-f2c08f28'
target_ref='refs/heads/code-simplifier/split-applyengine-69b2587cda46228e'
bundle_source_ref=$(git bundle list-heads "$bundle_path" | awk '$2 ~ /^refs\/heads\// { print $2 }')
if [ -z "$bundle_source_ref" ]; then
  bundle_source_ref=$(git bundle list-heads "$bundle_path" | awk '$2 == "HEAD" { print $2 }')
fi
if [ "$(printf '%s\n' "$bundle_source_ref" | sed '/^$/d' | wc -l | tr -d ' ')" != "1" ]; then
  echo "Expected exactly one bundle source ref, found: $bundle_source_ref" >&2
  exit 1
fi
git fetch "$bundle_path" "${bundle_source_ref}:${temp_ref}"
git update-ref "$target_ref" "$temp_ref"
git checkout 'code-simplifier/split-applyengine-69b2587cda46228e'
# Ensure the working tree matches the updated branch
git reset --hard
# Remove the temporary bundle ref
git update-ref -d "$temp_ref"

# Push the branch and create the pull request
git push origin code-simplifier/split-applyengine-69b2587cda46228e
gh pr create --title '[code-simplifier] Split ApplyEngine.cs into focused modules' --base main --head code-simplifier/split-applyengine-69b2587cda46228e --repo microsoft/testfx

Warning

Firewall blocked 9 domains

The following domains were blocked by the firewall during workflow execution:

  • 96bvsblobprodcus338.vsblob.vsassets.io
  • api.github.com
  • dc.services.visualstudio.com
  • github.com
  • kgfvsblobprodcus314.vsblob.vsassets.io
  • l49vsblobprodcus358.vsblob.vsassets.io
  • m6xvsblobprodcus342.vsblob.vsassets.io
  • pkgs.dev.azure.com
  • yluvsblobprodcus367.vsblob.vsassets.io

[!TIP]
api.github.com is blocked because GitHub API access uses the built-in GitHub tools by default. Instead of adding api.github.com to network.allowed, use tools.github.mode: gh-proxy for direct pre-authenticated GitHub CLI access without requiring network access to api.github.com:

tools:
  github:
    mode: gh-proxy

See GitHub Tools for more information on gh-proxy mode.

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "96bvsblobprodcus338.vsblob.vsassets.io"
    - "api.github.com"
    - "dc.services.visualstudio.com"
    - "github.com"
    - "kgfvsblobprodcus314.vsblob.vsassets.io"
    - "l49vsblobprodcus358.vsblob.vsassets.io"
    - "m6xvsblobprodcus342.vsblob.vsassets.io"
    - "pkgs.dev.azure.com"
    - "yluvsblobprodcus367.vsblob.vsassets.io"

See Network Configuration for more information.

🤖 Automated content by GitHub Copilot. Generated by the Code Simplifier workflow. · copilot · auto · 281.4 AIC · ⌖ 19.6 AIC · ⊞ 14.5K · [◷]( · ◷)

Add this agentic workflow to your repo

To install this agentic workflow, run

gh aw add githubnext/agentics/workflows/code-simplifier.md@main
  • expires on Oct 4, 2026, 2:51 PM UTC

Activity

  1. github-actions commented on Oct 4, 2026

    @github-actions
    ContributorAuthor

    This issue was automatically closed because it expired on 2026-10-04T14:51:14.923Z.

    Closed by Workflow

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions