Add isolated SwiftPM scratch placement and guarded cache cleanup - #524
Add isolated SwiftPM scratch placement and guarded cache cleanup#524morluto wants to merge 8 commits into
Conversation
- Add Scripts/cache_inventory.py to resolve SwiftPM scratch paths by repo/worktree + toolchain + target triple + configuration. - Wire scratch identity into conductor build/package/test/run/relaunch and install-debug-cli operations, and into package_app.sh and xcode_developer_workflow.sh. - Expand/resolve exact paths and developer-root paths, include SWIFT_TARGET_TRIPLE in cache key, and resolve/exclude symlinked managed worktree roots. - Drop the cache-identity sentinel; keyed directories are identified by repo-hash prefix. - Fix local production install path to use the package_app .build/release compatibility path and resolve it through symlinks. - Update test harnesses to match the new symlinked layout.
- Add plan_build_cache_cleanup and execute_build_cache_cleanup to cache_inventory.py with dry-run/apply/confirm and --limit support. - Re-validate each directory before rmtree: must still exist, not be a symlink, not have an active SwiftPM .lock, not be live-bound to the worktree, remain within the resolved scope (repo root, developer root, or exact path), and the worktree must not have become dirty. - Wire the "cache cleanup" subcommand into conductor (parser, OperationRegistry, internal runner, help) with default limit=None. - Add Scripts/test_cache_inventory.py and include it in conductor-selftest.
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
Current-main refresh on exact head |
Audit disposition — destructive-safety blocker (2026-08-14)The exact scratch path is canonicalized with Please retain the original path, |
Deep-review assessment — 2026-08-14Disposition: destructive-safety blocker. Preserve the original path, use |
Why
Worktrees accumulate independent multi-gigabyte
.builddirectories. Developers cannot place those caches under one controlled root or safely identify abandoned caches.Sharing one mutable scratch directory across divergent branches would trade disk pressure for correctness risk. This PR uses conservative worktree isolation, then builds cleanup on the same cache identity model.
Closes #421 and #422.
What changes
Placement
Adds
REPOPROMPT_DEVELOPER_SWIFTPM_SCRATCH_ROOT. Conductor derives an isolated path using repository, worktree, toolchain, destination, target triple, and configuration identity.The existing exact-path
REPOPROMPT_SWIFTPM_SCRATCH_PATHremains supported. Unset behavior stays checkout-local.Inventory and cleanup
One model owns effective path, identity, size, age, eligibility, and skip reasons. Cleanup defaults to dry-run. Mutation requires
--apply --confirmand immediately revalidates current/dirty/active/live-bound state, confinement, symlinks, and identity.Symlinked cache paths are skipped without resolving and deleting their targets. Cleanup never deletes worktree sources or Git metadata.
Compatibility
Packaging, local installation, and Xcode MCP workflows use the same scratch authority. The Xcode MCP compatibility link is refreshed after successful builds so it cannot retain an older executable.
Deliberate scope
This does not share one exact build directory across divergent worktrees. Isolation comes first; broader artifact sharing needs separate evidence.
Review order
Scripts/cache_inventory.pyidentity modelVerification