Skip to content

fix: exclude python cache from workspace archives - #156

Merged
delete-cloud merged 1 commit into
mainfrom
fix/workspace-archive-cache-excludes
May 14, 2026
Merged

delete-cloud merged 1 commit into
mainfrom
fix/workspace-archive-cache-excludes

Conversation

@delete-cloud

@delete-cloud delete-cloud commented May 14, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • exclude Python cache artifacts from workspace archive export
  • keep archive manifest counts aligned with exported archive contents
  • add regression coverage for pycache and .pyc filtering

Dogfood finding

Remote snapshot download brought back pycache from running python inside the remote workspace. This keeps generated Python cache files out of explicit archive download results.

Validation

  • uv run pytest tests/coding_agent/environment/test_workspace_archive.py tests/ui/test_http_server_workspace_transfer.py tests/coding_agent/environment/test_docker_workspace_provider_transfer.py -q
  • uv run basedpyright --level error src/coding_agent/workspace_archive.py src/coding_agent/environment/docker_workspace_provider.py tests/coding_agent/environment/test_workspace_archive.py tests/ui/test_http_server_workspace_transfer.py
  • uv run ruff format --check src/coding_agent/workspace_archive.py src/coding_agent/environment/docker_workspace_provider.py tests/coding_agent/environment/test_workspace_archive.py tests/ui/test_http_server_workspace_transfer.py
  • git diff --check

Summary by CodeRabbit

Release Notes

  • Bug Fixes

    • Workspace archives now properly exclude Python cache artifacts (__pycache__ directories and .pyc/.pyo files), resulting in cleaner, more efficient archives.
    • Improved consistency of file-exclusion rules across Docker workspace operations.
  • Tests

    • Added test for Python cache artifact exclusion.
    • Updated existing tests to verify cache exclusion behavior.

Review Change Stack

@coderabbitai

coderabbitai Bot commented May 14, 2026 •

Copy link
Copy Markdown
Contributor

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 18f3bc34-2096-4b87-815f-ac398841f931

📥 Commits

Reviewing files that changed from the base of the PR and between 0daa13e and 1943477.

📒 Files selected for processing (4)
  • coding-agent/src/coding_agent/environment/docker_workspace_provider.py
  • coding-agent/src/coding_agent/workspace_archive.py
  • coding-agent/tests/coding_agent/environment/test_workspace_archive.py
  • coding-agent/tests/ui/test_http_server_workspace_transfer.py

📝 Walkthrough

Walkthrough

The PR refactors workspace archive path exclusion by introducing a centralized helper function that consolidates exclusion rules for preserved root names, Python cache directories (__pycache__), and bytecode files (.pyc, .pyo). The archive builder and manifest generator now use this helper, with manifest generation adding special path normalization for __pycache__ references. Tests are added and updated to verify correct exclusion behavior.

Changes

Workspace Archive Exclusion Rules

Layer / File(s) Summary
Exclusion configuration and helper function
coding-agent/src/coding_agent/workspace_archive.py
Introduces _EXCLUDED_DIRECTORY_NAMES and _EXCLUDED_FILE_SUFFIXES constants, and implements should_exclude_workspace_archive_path(relative: Path) -> bool to centralize exclusion decisions for preserved root names, __pycache__ directories, and .pyc/.pyo files.
Archive building and manifest generation integration
coding-agent/src/coding_agent/environment/docker_workspace_provider.py, coding-agent/src/coding_agent/workspace_archive.py
Archive building loop delegates exclusion decisions to the new helper. Manifest generation imports and uses the same helper, with additional logic to collapse __pycache__ subpaths to the directory prefix when recording excluded files.
Test coverage for cache artifact exclusion
coding-agent/tests/coding_agent/environment/test_workspace_archive.py, coding-agent/tests/ui/test_http_server_workspace_transfer.py
New test verifies workspace archive excludes __pycache__ and .pyc artifacts while preserving app.py. Existing manifest test is updated to expect __pycache__ in the excluded files list.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related PRs

  • delete-cloud/Coding-Agent-Loop#117: Both PRs directly modify the workspace archive creation/exclusion behavior and related UI tests to ensure excluded paths like .git and __pycache__ are properly filtered.
  • delete-cloud/Coding-Agent-Loop#127: Both PRs touch workspace archive/manifest generation in docker_workspace_provider.py, with the main PR refining exclusion rules for __pycache__/.pyc while the retrieved PR adds the underlying remote workspace archive/manifest APIs.

Poem

🐰 In archives deep, where cache files creep,
Now __pycache__ sleeps with .pyc so steep!
One helper rules them all with logic neat,
No clutter left—just source code sweet! 🐍✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'fix: exclude python cache from workspace archives' accurately and specifically describes the primary change: implementing exclusion of Python cache artifacts (pycache and .pyc files) from workspace archives.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/workspace-archive-cache-excludes

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@delete-cloud
delete-cloud merged commit 9a1dfce into main May 14, 2026
1 check passed
@delete-cloud
delete-cloud deleted the fix/workspace-archive-cache-excludes branch May 14, 2026 09:23
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.

1 participant