You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[BUG] apm install rewrites generated_at on every run when SHA-pinned deps carry resolved_tag (lockfile_version mismatch) #3433
Version: 0.33.0 (18c4c43); the same code is on main today.
What happens
On a project whose committed apm.lock.yaml has lockfile_version: '2' because some SHA-pinned dependencies carry resolved_tag, every apm install (no dependency change) rewrites the lock: only generated_at changes, so git status is dirty after each install.
Cause
The install builds the new lock in memory without resolved_tag, so its lockfile_version is '1'.
_preserve_existing_revision_pin_tags (src/apm_cli/install/phases/lockfile.py) then copies resolved_tag back onto unchanged SHA-pinned entries by setting dep.resolved_tag directly, without re-deriving lockfile_version (only add_dependency promotes it).
_write_if_changed calls LockFile.is_semantically_equivalent, which compares lockfile_version first (src/apm_cli/deps/lockfile.py): '1' != '2', so it returns False and the lock is saved with a new generated_at. All dependency, MCP and LSP fields compare equal.
Reproduce
A lock with at least one dependency pinned by commit SHA whose entry has resolved_tag (written when that commit matches a tag), committed as lockfile_version: '2'. Run apm install twice: the second run rewrites generated_at.
Suggested fix
Re-derive lockfile_version (or call the same promotion logic as add_dependency) after _preserve_existing_revision_pin_tags, or have is_semantically_equivalent compare the version each lock would require for its contents rather than the stored field.
Workaround and its problem
Regenerating the lock from scratch avoids the mismatch, but drops MCP ownership records for already-committed configs, as in #3090.
I checked the reported path on main 2920043258932f0f67e6f01df7b9047eb42f358c: _preserve_existing_revision_pin_tags assigns resolved_tag after dependency construction and before the semantic write check; add_dependency performs eager v2 promotion. That is consistent with your explanation, but I have not independently run the reported install sequence.
Would a responsible maintainer welcome a bounded fix to keep the in-memory lock schema version consistent after preserving the tag, without dropping metadata or changing actual dependency resolution? Suggested acceptance: an isolated synthetic real-CLI fixture shows two unchanged installs preserve the lock bytes and timestamp for an unchanged SHA/ref/tag; changed refs still write the correct update; v1 and v3/replacement lock cases retain their proper schema behavior; existing MCP ownership and unrelated lock entries survive. This is a proposal, not approval or an implementation. Please specify a review contact and any preferred schema-version rule before automation work starts.
Activity
dajiaohuang commentedon Nov 1, 2026
I checked the reported path on main
2920043258932f0f67e6f01df7b9047eb42f358c:_preserve_existing_revision_pin_tagsassignsresolved_tagafter dependency construction and before the semantic write check;add_dependencyperforms eager v2 promotion. That is consistent with your explanation, but I have not independently run the reported install sequence.Would a responsible maintainer welcome a bounded fix to keep the in-memory lock schema version consistent after preserving the tag, without dropping metadata or changing actual dependency resolution? Suggested acceptance: an isolated synthetic real-CLI fixture shows two unchanged installs preserve the lock bytes and timestamp for an unchanged SHA/ref/tag; changed refs still write the correct update; v1 and v3/replacement lock cases retain their proper schema behavior; existing MCP ownership and unrelated lock entries survive. This is a proposal, not approval or an implementation. Please specify a review contact and any preferred schema-version rule before automation work starts.