Repository navigation
refactor(install): split lockfile phase helpers to restore the module size budget - #4155
Conversation
… size budget Move the three best-effort cache pin marker syncs out of LockfileBuilder into install/phases/lockfile_cache_pins.py, owned with install/cache_pin.py (locked-copy-validity). No behavior change; phases/lockfile.py drops from 1017 to 940 lines, back under the 1000-line install module budget. Part of #3701 Co-authored-by: copilot-swe-agent[bot] <[email protected]>
apm-spec-waiver: pure code move of cache-pin helpers to restore the install module size budget, no behavior change Co-authored-by: copilot-swe-agent[bot] <[email protected]>
|
Landing over one known flake, per the 0.37 Hardening PM decision (steward-accepted root cause): Build & Test Shard 2 fails only on tests/unit/deps/test_git_reference_resolver.py::TestResolveCommitShaForRef::test_best_effort_rate_limit_falls_through_without_retry_wait (the test patches the global time.sleep and counts other threads' polls; 1 failed, 14871 passed). The fix is P-3 (e401b1fb), in flight. The flake is unrelated to this diff (lockfile.py 1017 -> 940 plus the new lockfile_cache_pins.py, no behavior change). All other checks pass, including Spec conformance (waiver accepted). |
Co-authored-by: copilot-swe-agent[bot] <[email protected]>
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues block the cache pin helper extraction.
No open issues 🎉
What changed in this PR
This refactor restores the install module size budget by extracting cache pin marker synchronization from LockfileBuilder, supporting the follow-up cleanup work for #3701 without changing behavior.
Changes:
- Moves three best-effort cache pin helpers into a dedicated module, preserving call order and lazy imports.
- Reduces
lockfile.pyto 940 lines, below the 1,000-line install module limit. - Updates test patch targets and registers the extracted module under the existing architecture owner.
| File | Description |
|---|---|
tests/unit/install/phases/test_lockfile_orphan_prune.py |
Patches the extracted functions at their lockfile-phase call sites. |
src/apm_cli/install/phases/lockfile.py |
Delegates marker synchronization to the extracted helpers. |
src/apm_cli/install/phases/lockfile_cache_pins.py |
Contains the three existing best-effort marker synchronization helpers. |
.apm/architecture/owners/install-deployment.json |
Adds the helper module to the locked-copy-validity selectors. |
Review effort: Balanced
Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Description
mainis red:install/phases/lockfile.pyis 1017 lines, over the 1000-line install module budget intests/unit/install/test_architecture_invariants.py::test_no_install_module_exceeds_loc_budget. It got there when #4021 (orphan owner) and #4023 (receipt plumbing) landed together. Every PR based onmainfails this test.This PR restores the budget without raising it. It moves one cohesive block of existing code out of
LockfileBuilder: the three best-effort.apm-pincache pin marker syncs.LockfileBuilder(phases/lockfile.py)install/phases/lockfile_cache_pins.py_sync_cache_pin_markers(self, lockfile)sync_cache_pin_markers(ctx, lockfile)_sync_cache_pin_markers_from_existing(self)sync_cache_pin_markers_from_existing(ctx)_sync_cache_pin_markers_from_disk(self)sync_cache_pin_markers_from_disk(ctx)self.ctxchanged toctx.build_and_savecalls them at the same three points. The lazyinstall.cache_pinimports stay, so existing patches ofsync_markers_for_lockfilestill apply.phases/lockfile.pygoes from 1017 to 940 lines; the new module has 100.locked-copy-validityin.apm/architecture/owners/install-deployment.json. That owner already holdsinstall/cache_pin.pyand the.apm-pinmarker contract. No architecture guard names the moved methods.tests/unit/install/phases/test_lockfile_orphan_prune.pynow monkeypatches the module-level functions instead of the removed methods.Issue and approved scope
Issue: Refs #3701 (Part of #3701). This unblocks #4049, which finishes #3701.
Human scope-approval comment: #3701 (comment). The 0.37 Stream H lead requested this split to restore
main.Does this PR complete the issue, or what remains? No. #4049 completes #3701.
Type of change
Testing
ruff checkandruff format --checkpass on the touched files. The host is overloaded, so CI validates the rest.Changelog
Spec conformance (OpenAPM v0.1)