Dead-code Removal Rotation Worker

July 30, 2026 ยท View on GitHub

You are responsible for safely removing one dead-code candidate per run and opening a verified cleanup PR.

Pre-activation context

A deterministic pre-activation step has already selected the candidate and analyzed its references. Use only the values below.

  • Candidate found: ${{ needs.pre_activation.outputs.found }}
  • Symbol: ${{ needs.pre_activation.outputs.symbol }}
  • Package: ${{ needs.pre_activation.outputs.package }}
  • File: ${{ needs.pre_activation.outputs.file }}
  • Line: ${{ needs.pre_activation.outputs.line }}
  • Column: ${{ needs.pre_activation.outputs.column }}
  • Companion test cleanup eligible: ${{ needs.pre_activation.outputs.companion_test_cleanup_eligible }}
  • Companion test file: ${{ needs.pre_activation.outputs.companion_test_file }}
  • Impacted packages: ${{ needs.pre_activation.outputs.impacted_packages }}
  • Reference files: ${{ needs.pre_activation.outputs.reference_files }}
  • Reference file count: ${{ needs.pre_activation.outputs.reference_file_count }}

Recent outcome summary

${{ needs.pre_activation.outputs.summary }}

Pre-activation filtered candidates

Before proceeding with the main task, record the following candidates that pre-activation filtered due to invalid or excluded references. This avoids repeating costly gopls analysis on future runs.

${{ needs.pre_activation.outputs.filtered_candidates }}

Run:

echo '${{ needs.pre_activation.outputs.filtered_candidates }}' | jq '[.[] | {symbol, package}]' | \
go run ./scripts/ci-deadcode-removal-rotation record-batch \
  --memory /tmp/gh-aw/repo-memory/ci-deadcode-removal-rotation/memory/ci-deadcode-removal-rotation/memory.json \
  --reason invalid_candidate_references

After recording the filtered candidates, proceed with the main task below.

Task

  1. Read the candidate file (${{ needs.pre_activation.outputs.file }}) and locate the dead function at line ${{ needs.pre_activation.outputs.line }}.

  2. Remove the dead function including its doc comment block. Ensure the file remains syntactically valid.

  3. Companion test cleanup (conditional):

    • Only if ${{ needs.pre_activation.outputs.companion_test_cleanup_eligible }} is true:
      • Read the companion test file ${{ needs.pre_activation.outputs.companion_test_file }}.
      • Before deleting any tests, search the file for the strings resource.Test or resource.ParallelTest.
      • If either string is present, abort immediately without making any changes.
        • Record the attempt as invalid_candidate_acceptance_test using:

          go run ./scripts/ci-deadcode-removal-rotation record \
            --memory /tmp/gh-aw/repo-memory/ci-deadcode-removal-rotation/memory/ci-deadcode-removal-rotation/memory.json \
            --symbol "${{ needs.pre_activation.outputs.symbol }}" \
            --package "${{ needs.pre_activation.outputs.package }}" \
            --reason invalid_candidate_acceptance_test \
            --context '{"referenceFileCount":${{ needs.pre_activation.outputs.reference_file_count }},"testCleanupEligible":true}'
          
        • Then call noop with a concise reason.

      • If the backstop passes, remove only the test functions that reference ${{ needs.pre_activation.outputs.symbol_name }} (and their doc comments).
    • If ${{ needs.pre_activation.outputs.companion_test_cleanup_eligible }} is false:
      • Do not delete any tests. Only remove the dead symbol.
  4. Verify the cleanup before opening a PR:

    • Run timeout 600 make build (10-minute timeout). If it fails or times out:

      • Record the attempt as build_failed (or verification_timeout on timeout):

        go run ./scripts/ci-deadcode-removal-rotation record \
          --memory /tmp/gh-aw/repo-memory/ci-deadcode-removal-rotation/memory/ci-deadcode-removal-rotation/memory.json \
          --symbol "${{ needs.pre_activation.outputs.symbol }}" \
          --package "${{ needs.pre_activation.outputs.package }}" \
          --reason <reason>
        
      • Stop without creating a PR.

    • Run unit tests for the impacted packages:

      go test -v ${{ needs.pre_activation.outputs.impacted_packages }}
      

      If any test fails:

      • Record the attempt as tests_failed.
      • Stop without creating a PR.
  5. Format the cleaned files:

    • Run make fmt.
  6. Open a cleanup PR using the create-pull-request safe output only if verification succeeds.

    • Title format: [deadcode] Remove ${{ needs.pre_activation.outputs.symbol }}
    • Body must include:
      • A short description of the removed symbol.
      • The recent outcome summary.
      • A note that the PR was generated by the dead-code removal rotation workflow and that maintainers should review, merge, or close it manually.
  7. Record success after opening the PR:

    go run ./scripts/ci-deadcode-removal-rotation record \
      --memory /tmp/gh-aw/repo-memory/ci-deadcode-removal-rotation/memory/ci-deadcode-removal-rotation/memory.json \
      --symbol "${{ needs.pre_activation.outputs.symbol }}" \
      --package "${{ needs.pre_activation.outputs.package }}" \
      --reason pr_created \
      --context '{"referenceFileCount":${{ needs.pre_activation.outputs.reference_file_count }},"testCleanupEligible":${{ needs.pre_activation.outputs.companion_test_cleanup_eligible }}}'
    
  8. If you cannot safely proceed at any point, record the appropriate reason code and call noop.

Guardrails

  • Never modify more than one dead symbol per run.
  • Never delete tests unless pre-activation has explicitly marked the candidate as eligible for companion test cleanup.
  • Never bypass the resource.Test / resource.ParallelTest backstop.
  • Do not open a PR if verification fails.
  • Keep changes minimal and focused.