Repository navigation
fix(lockfile): rewrites keep lockfile_version 2 or later (req-lk-002) - #4372
Merged
Daniel Meppiel (danielmeppiel) merged 8 commits intoNov 21, 2026
Merged
Daniel Meppiel (danielmeppiel) merged 8 commits into
Daniel Meppiel (danielmeppiel) merged 8 commits into
Conversation
req-lk-002: LockFile.write reads the existing lockfile's version, and a rewrite of a lockfile at version 2 or later never emits version 1. Versions 3 and 4 stay content-derived. Co-authored-by: copilot-swe-agent[bot] <[email protected]>
A rewrite of an existing lockfile at version 2 or later never writes version 1, for registry and git-semver entries alike. Versions 3 and 4 follow their own rules: version 4 still tracks framed package content hashes. Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Daniel Meppiel (danielmeppiel)
requested a review
from Sergio Sisternes (sergio-sisternes-epam)
as a code owner
November 20, 2026 15:17
Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
The three filesystem-based tests are in a unit-marked module that requires pure logic without filesystem access and must be moved to a component-marked module.
1 open issue
What changed in this PR
This PR fixes #4232 by preserving the version-2 boundary when rewriting an existing lockfile, as required by OpenAPM req-lk-002, while retaining the separate rules for versions 3 and 4.
Changes:
- Applies a version-2 floor before comparing an existing lockfile for semantic equivalence.
- Adds regression coverage for dependency removal, framed-hash version handling, and new version-1 lockfiles.
- Documents the user-visible fix in the changelog.
| File | Description |
|---|---|
tests/unit/test_lockfile_v2_bump.py |
Adds rewrite and version-boundary regression tests. |
tests/integration/test_lockfile_version_monotonic_lifecycle.py |
Checks version preservation through CLI install, uninstall, and reinstall. |
src/apm_cli/deps/lockfile.py |
Prevents rewrites of existing version-2-or-later lockfiles from emitting version 1. |
CHANGELOG.md |
Records the lockfile rewrite fix. |
Review effort: Balanced
Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Co-authored-by: copilot-swe-agent[bot] <[email protected]>
5 of 10 tasks
Co-authored-by: copilot-swe-agent[bot] <[email protected]>
5 of 10 tasks
Daniel Meppiel (danielmeppiel)
deleted the
danielmeppiel-4232-lock-version-monotonic
branch
November 21, 2026 05:24
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Description
A rewrite of an existing lockfile at
lockfile_version2 or later never writes version 1 (OpenAPM req-lk-002), for registry and git-semver entries alike.LockFile.writereads the existing lockfile it replaces and applies a version-2 floor before the semantic-equivalence check. Versions 3 and 4 follow their own requirements: version 4 still tracks framed package content hashes, so the floor is 2, not the previous maximum.Issue and approved scope
Issue: Fixes #4232
Human scope-approval comment: #4232 (apm-scope:v1 record by Daniel Meppiel (@danielmeppiel))
Completes the issue. Starts from Daniel Meppiel (@danielmeppiel)'s unit slice (9582695).
Type of change
Testing
Tested locally
All existing tests pass
Added tests for new functionality (if applicable)
tests/unit/test_lockfile_v2_bump.py::TestSchemaBumpOpportunistic::test_rewrite_keeps_v2_after_the_v2_entry_is_removed[registry|git-semver]-- registry and git-semver triggers.tests/unit/test_lockfile_v2_bump.py::TestSchemaBumpOpportunistic::test_v4_marker_follows_framed_content_hashes_not_the_floor-- version 4 follows framed hashes; the floor only excludes version 1.tests/integration/test_lockfile_version_monotonic_lifecycle.py::test_lockfile_version_is_kept_after_the_v2_dependency_is_removed-- installed CLI: install a git-semver dependency into a version 2 lockfile, uninstall it, reinstall; the version is never 1.Commands run:
APM_BINARY_PATH=.venv/bin/apm uv run --extra dev pytest tests/integration/test_lockfile_version_monotonic_lifecycle.py tests/unit/test_lockfile_v2_bump.py -n0 -q-- 35 passed.uv run --extra dev pytest tests/unit -k "lockfile or lock_" -n 8 -q-- 1292 passed; 3 failures are environment-only (gpg-signed fixture commits, root-run installer) and fail identically on main.uv run --extra dev ruff check/ruff format --checkover src/ tests/ scripts -- clean.python -m tests.quality.taxonomy --changed-- clean.Changelog
## [Unreleased]inCHANGELOG.md.Spec conformance (OpenAPM v0.1)
@pytest.mark.req("req-lk-002")on the installed-CLI test.CONFORMANCE.{md,json}regenerated; no change on this base.