Repository navigation
fix: user-lockfile deployment rows record user scope - #4375
Daniel Meppiel (danielmeppiel) wants to merge 8 commits into
Conversation
Rows persisted in the user lockfile ($APM_HOME/apm.lock.yaml) record scope user, and a path under a target's user root outside HOME records a target-relative value under that root, per the lockfile spec's canonical deployment rows. DeploymentLedgerCodec owns the persisted form; in memory rows keep their compatibility values, so rows in the earlier form read without drift and are rewritten on the next lockfile write. The user lockfile is identified through core.scope.is_user_scope_root. Fixes #4248 Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Co-authored-by: copilot-swe-agent[bot] <[email protected]>
There was a problem hiding this comment.
🟡 Changes recommended
Suffix matching across targets and collision fallbacks still produce invalid project-relative locators or project-scoped rows in user lockfiles for supported deployment configurations.
2 open issues
What changed in this PR
This PR addresses #4248 by normalizing user-lockfile deployment rows in the canonical ledger codec while preserving their in-memory compatibility form.
Changes:
- Persist user scope and target-relative paths for deployments under external target roots.
- Add lockfile read/write hooks to translate between persisted and compatibility forms.
- Add lifecycle coverage for legacy rows, no-op installs, subsequent writes, and uninstall cleanup.
| File | Description |
|---|---|
tests/integration/test_claude_config_profile_lifecycle.py |
Tests row formats and lifecycle behavior inside and outside HOME. |
tests/fixtures/lifecycle_bug_ledger.json |
Records regression coverage for #4248. |
src/apm_cli/deps/lockfile.py |
Connects serialization and loading to the ledger codec. |
src/apm_cli/core/deployment_ledger.py |
Implements user-row persistence and compatibility translation. |
CHANGELOG.md |
Documents the user-lockfile format correction. |
Review effort: Balanced
Persisted user-form rows map back to their in-memory form by content, so every reader (read, a staged or withheld document, the write-time parse) sees the same rows whatever its environment. The m_spine user-scope row check asserts the persisted rows and no longer tracks a known failure. Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Co-authored-by: copilot-swe-agent[bot] <[email protected]>
A project lockfile's recorded scope is evidence, so only the user lockfile (decided through core.scope) maps its persisted rows back. The global receipt oracle reads the user lockfile as the CLI does. Co-authored-by: copilot-swe-agent[bot] <[email protected]>
# Conflicts: # CHANGELOG.md # tests/fixtures/lifecycle_bug_ledger.json
A staged user lockfile maps its user-form rows back on read, as the disk branch does (#4375). Co-authored-by: copilot-swe-agent[bot] <[email protected]>
… rows A path under any target's user root outside HOME is target-relative, whatever other targets deploy the same relative path. Plain user-scoped keys are reserved first, so a target-relative form that would collide keeps the row project-relative and every row still records scope user. Reading resolves each target-relative row per target: the path under the target's resolved root, then the one candidate no other row takes. Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Co-authored-by: Copilot App <[email protected]>
The global receipt oracle first checks the persisted user-lockfile rows directly (scope user, target-relative to each target root outside HOME), so a codec defect that corrupted both write and read could not pass. Co-authored-by: copilot-swe-agent[bot] <[email protected]>
|
Closing as superseded: this change shipped in v0.37.0 through the release train (#4424). Its core source and test files are byte-identical on main, and the linked issues are closed as completed in 0.37.0. The only remaining differences are in shared files that every train PR touches (CHANGELOG, bug ledger, owner registry). Nothing is left to land. -- regent, 0.37 milestone close-out |

Description
User-scope consistency for lockfile deployment rows. Rows in the user lockfile (
$APM_HOME/apm.lock.yaml) now match the lockfile spec's canonical deployment rows:scope: user;CLAUDE_CONFIG_DIRelsewhere) recordskind: target-relativewith a value relative to that root; a root inside HOME keepsproject-relativevalues from the user deploy root.DeploymentLedgerCodecowns the persisted form (persisted_rows,user_lockfile_rows,adopt_user_lockfile_rows). In memory, rows keep their compatibility values, so every consumer is unchanged. Reading the user lockfile maps its rows back (a target-relative value resolves through the lock's own compatibility views); a project lockfile's recorded scope stays evidence and reads unchanged. Rows in the earlier form read without drift and are rewritten on the next lockfile write. The writer identifies the user lockfile through the scope owner,core.scope.is_user_scope_root.LockFilekeeps only one-line hooks into_yaml,writeandread.Issue and approved scope
Issue: Fixes #4248
Human scope-approval comment: #4248 (comment)
Does this PR complete the issue, or what remains? Completes it.
Type of change
Testing
tests/integration/test_claude_config_profile_lifecycle.py::test_user_lockfile_rows_record_user_scope[home]tests/integration/test_claude_config_profile_lifecycle.py::test_user_lockfile_rows_record_user_scope[outside-home]tests/lifecycle/machines/test_m_spine.py::test_global_install_records_user_scope_deployment_rows(no longer an expected failure)Each case asserts the exact row forms, a byte-stable no-op install over a lock still in the earlier form, the new form after the next write, and that uninstall removes exactly the deployed files. The whole module passes (17 tests), as do
test_required_global_audit_rule_matrix_for_external_roots, the unit suites for core, deps, install, commands and integration, and the global, user-scope, copilot-home, cold-restore and cleanup-evidence lifecycle modules. Ledger row added for #4248 (portability.byte_deterministic,outcome.status_matches_state).Changelog
## [Unreleased]inCHANGELOG.md.Spec conformance (OpenAPM v0.1)