Skip to content

fix: user-lockfile deployment rows record user scope - #4375

Closed
Daniel Meppiel (danielmeppiel) wants to merge 8 commits into
mainfrom
danielmeppiel-h-e-4248
Closed

Daniel Meppiel (danielmeppiel) wants to merge 8 commits into
mainfrom
danielmeppiel-h-e-4248

Conversation

@danielmeppiel

@danielmeppiel Daniel Meppiel (danielmeppiel) commented Nov 20, 2026 •

Copy link
Copy Markdown
Collaborator

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:

  • every row records scope: user;
  • a path under a target's user root outside HOME (for example CLAUDE_CONFIG_DIR elsewhere) records kind: target-relative with a value relative to that root; a root inside HOME keeps project-relative values from the user deploy root.

DeploymentLedgerCodec owns 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. LockFile keeps only one-line hooks in to_yaml, write and read.

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

  • Bug fix
  • New feature
  • Documentation
  • Maintenance / refactor

Testing

  • Tested locally
  • All existing tests pass
  • Added tests for new functionality (if applicable)
Cell Node id Branch
install -g into a Claude profile inside HOME, then the earlier row form, then uninstall -g tests/integration/test_claude_config_profile_lifecycle.py::test_user_lockfile_rows_record_user_scope[home] green
the same with the profile root outside HOME tests/integration/test_claude_config_profile_lifecycle.py::test_user_lockfile_rows_record_user_scope[outside-home] green
install --global, generated reference model tests/lifecycle/machines/test_m_spine.py::test_global_install_records_user_scope_deployment_rows (no longer an expected failure) green

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

  • One line in one section under ## [Unreleased] in CHANGELOG.md.
  • N/A -- internal-only change (CI, tests, refactor).

Spec conformance (OpenAPM v0.1)

  • N/A -- this PR does not change OpenAPM-observable behaviour.

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]>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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

Comment thread src/apm_cli/core/deployment_ledger.py Resolved
Comment thread src/apm_cli/core/deployment_ledger.py Resolved
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]>
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
Daniel Meppiel (danielmeppiel) added a commit that referenced this pull request Nov 20, 2026
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]>
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]>
@danielmeppiel Daniel Meppiel (danielmeppiel) added the full-integration Run the full integration suite (ci-integration.yml) on this PR before merge label Nov 20, 2026
@danielmeppiel

Copy link
Copy Markdown
Collaborator Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

full-integration Run the full integration suite (ci-integration.yml) on this PR before merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Global install records user-lockfile deployment rows as scope project with absolute project-relative values

2 participants