Repository navigation
[0.37 candidate] fix(lockfile): user-scope bundle rows keep scope: user (#3995) - #4024
Merged
Daniel Meppiel (danielmeppiel) merged 3 commits intoNov 20, 2026
Conversation
Daniel Meppiel (danielmeppiel)
force-pushed
the
danielmeppiel-3995-user-scope-bundle-rows
branch
from
November 20, 2026 00:52
96032d9 to
361d523
Compare
Daniel Meppiel (danielmeppiel)
added a commit
that referenced
this pull request
Nov 20, 2026
Daniel Meppiel (danielmeppiel)
added a commit
that referenced
this pull request
Nov 20, 2026
Daniel Meppiel (danielmeppiel)
force-pushed
the
danielmeppiel-3995-user-scope-bundle-rows
branch
from
November 20, 2026 01:18
361d523 to
c6608d5
Compare
Daniel Meppiel (danielmeppiel)
changed the base branch from
danielmeppiel-0-37-owner-hardening-b
to
danielmeppiel-miniature-happiness
November 20, 2026 01:18
Daniel Meppiel (danielmeppiel)
force-pushed
the
danielmeppiel-miniature-happiness
branch
from
November 20, 2026 01:48
d887360 to
c57ac3e
Compare
Merged
5 of 10 tasks
Daniel Meppiel (danielmeppiel)
force-pushed
the
danielmeppiel-miniature-happiness
branch
from
November 20, 2026 01:58
c57ac3e to
2d129a0
Compare
The bundle writer takes its install scope as a required keyword-only argument, and a ledger rebuild carries the scope of an unambiguous surviving bundle claim (prior ledger or supplied provenance) instead of re-deriving it from the path prefix. Owners, hashes and target attribution are kept; project bundles stay project. No lock field or version change. Refs #3995 Co-authored-by: copilot-swe-agent[bot] <[email protected]>
…pe (#3995) Refs #3995 Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Refs #3995 Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Daniel Meppiel (danielmeppiel)
force-pushed
the
danielmeppiel-3995-user-scope-bundle-rows
branch
from
November 20, 2026 02:11
c6608d5 to
10740d2
Compare
12 of 19 tasks
Daniel Meppiel (danielmeppiel)
added a commit
that referenced
this pull request
Nov 20, 2026
Daniel Meppiel (danielmeppiel)
added a commit
that referenced
this pull request
Nov 20, 2026
Daniel Meppiel (danielmeppiel)
added a commit
that referenced
this pull request
Nov 20, 2026
Daniel Meppiel (danielmeppiel)
added a commit
that referenced
this pull request
Nov 20, 2026
…ation cases (#3994) The content-hash MutationCase block from #4024 was out of guard-id order (test_matrix_case_order_is_deterministic); moved into sorted position. Co-authored-by: Copilot App <[email protected]>
Daniel Meppiel (danielmeppiel)
added a commit
that referenced
this pull request
Nov 20, 2026
Daniel Meppiel (danielmeppiel)
added a commit
that referenced
this pull request
Nov 20, 2026
Daniel Meppiel (danielmeppiel)
added a commit
that referenced
this pull request
Nov 20, 2026
Daniel Meppiel (danielmeppiel)
added a commit
that referenced
this pull request
Nov 20, 2026
Daniel Meppiel (danielmeppiel)
marked this pull request as ready for review
November 20, 2026 03:50
Daniel Meppiel (danielmeppiel)
requested a review
from Sergio Sisternes (sergio-sisternes-epam)
as a code owner
November 20, 2026 03:50
Daniel Meppiel (danielmeppiel)
added a commit
that referenced
this pull request
Nov 20, 2026
Daniel Meppiel (danielmeppiel)
added a commit
that referenced
this pull request
Nov 20, 2026
Daniel Meppiel (danielmeppiel)
added a commit
that referenced
this pull request
Nov 20, 2026
Daniel Meppiel (danielmeppiel)
added a commit
that referenced
this pull request
Nov 20, 2026
Daniel Meppiel (danielmeppiel)
added a commit
that referenced
this pull request
Nov 20, 2026
Daniel Meppiel (danielmeppiel)
added a commit
that referenced
this pull request
Nov 20, 2026
Daniel Meppiel (danielmeppiel)
added a commit
that referenced
this pull request
Nov 20, 2026
Daniel Meppiel (danielmeppiel)
added a commit
that referenced
this pull request
Nov 20, 2026
Daniel Meppiel (danielmeppiel)
deleted the
danielmeppiel-3995-user-scope-bundle-rows
branch
November 20, 2026 06:42
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
TL;DR
After
apm install -g <bundle>, the bundle's rows in$APM_HOME/apm.lock.yamlsaidscope: project. The bundle writer had no scope, and every ledger rebuild re-derived scope from the path prefix, where only.copilot/counts as user. This PR fixes it inside the canonical owner,DeploymentLedgerCodec, using the existing per-rowscopefield. No lock field, lockfile version or spec changes.Fixes #3995
Note
Restacked directly above #4026: base
danielmeppiel-miniature-happinessat2d129a05, which sits on #4008 at3560d7f8on #3290; head10740d2c. Only this PR's 3 commits were rebased (git rebase --onto 2d129a05 d8873601). The patch is byte-identical to the previous head apart from CHANGELOG context; the only conflict was the CHANGELOG line, kept at the bottom ofFixed, and there were no docs conflicts. CI does not run for a non-mainbase, so the evidence below is local, from this cloud workspace.Problem (WHY)
record_local_bundle_filestook no scope, so its rows got the path-prefix guess (legacy_scope):projectfor every-gpath except.copilot/._rebuild_from_legacyruns on every ledger write and re-derives scope. Its carry-over key includesscope, and bundle paths are excluded from preferred locators, so even a correctuserrow flipped back toprojecton the next unrelated-ginstall.-g --frozenandaudit --cipassed regardless. The label was misleading to anyone reading the lock, and tolocator_in_scope, which only excludes a row from another scope when its recorded scope differs from the guess.Approach (WHAT)
record_local_bundle_files(..., *, scope: InstallScope, ...): required and keyword-only, with no default, so the owner never guesses. The rows it writes record that scope._rebuild_from_legacycarries the recorded scope of each surviving bundle claim. It reads_bundle_scopes, taking the prior ledger first and then supplied provenance, and only when one source records a single scope for that path. Owners, hash and target attribution come from the rebuild as before.replace_legacy_owner(..., provenance=...)passes provenance bundle scopes, so a freshly built lockfile keeps them too.install/local_bundle_handler.py, passes its existingscope(USERfor-g).Implementation (HOW)
src/apm_cli/core/deployment_ledger.py: the new_bundle_scopes()collects recorded bundle scopes and leaves an ambiguous path to the rebuild's own scope._mark_local_bundle_paths(..., scopes=)re-keys a row whose scope changes, since the key includes scope.legacy_scopeandlocator_in_scopeare unchanged.src/apm_cli/install/local_bundle_handler.py: one keyword argument added.scope=InstallScope.PROJECT.tests/unit/core/test_bundle_row_scope.pyis new, with 9 cases.tests/integration/test_user_scope_bundle_rows_lifecycle.pyis new and uses the installed CLI with isolated HOME and APM_HOME.reference/lockfile-spec.md, rowscopenow reads "project, oruserfor rows in the user lockfile". One CHANGELOG line, at the bottom ofFixed.Trade-offs
scopefield rather than adding a bundle-scope field, as the record requires. No lock migration and no version bump.legacy_scope, and the 0.37 known-issue release note is not touched.Benefits
scope: useron install and after any later-ginstall.locator_in_scope(row, "project")is nowFalsefor those rows, so they stay out of project provenance lookups.scope: project), with no new lock data.Validation (local; base
2d129a05, head10740d2c)uvx [email protected] check src/ tests/ scripts/lint_architecture_boundaries.py scripts/architecture_linter/anduvx [email protected] format --check(same paths)uv run --extra dev python -m pylint --disable=all --enable=R0801 --min-similarity-lines=10 --fail-on=R0801 src/apm_cli/ scripts/lint_architecture_boundaries.py scripts/architecture_linter/relative_toci.ymlone-liners (2100-line cap)bash scripts/lint-auth-signals.shbash scripts/lint-architecture-boundaries.shuv run --extra dev pytest -q -n 2 tests/unit/core/test_bundle_row_scope.py tests/unit/core/test_deployment_state.py tests/unit/deps/test_lockfile_local_staging.py tests/unit/install/test_empty_replacement_table.py tests/unit/install/test_local_rows_need_reconciling.py tests/unit/install/test_architecture_invariants.pyAPM_BINARY_PATH=$PWD/.venv/bin/apm uv run --extra dev pytest -q -n 2 tests/integration/test_user_scope_bundle_rows_lifecycle.py tests/integration/test_local_bundle_mcp_lifecycle.py tests/integration/test_install_local_bundle_e2e.py tests/integration/test_global_install_e2e.py tests/integration/test_local_shared_root_skill_cleanup.py tests/integration/test_global_audit_deploy_root.py tests/integration/test_lock_derived_expected_state_lifecycle.py tests/integration/test_mcp_dependency_targets_lifecycle.pyuv run --extra dev pytest -q -n 2 -p no:randomly tests/spec_conformance2d129a05(test_mode_b_detector8,test_resolution_reqs1; sandbox git)Mutation checks (unchanged by the rebase): with
src/reverted, all original unit tests fail and the lifecycle test fails withassert 'project' == 'user'. The two follow-up tests each fail under a targeted mutation of their rule.Scenario Evidence
apm install -g <bundle>and another unrelated-ginstall, the bundle rows keep their home-relative path,scope: user, owners and hash;-g --frozenandaudit --cifrom$APM_HOMEpasstests/integration/test_user_scope_bundle_rows_lifecycle.py::test_user_bundle_rows_keep_user_scope_across_an_unrelated_rebuild(regression trap for #3995)tests/unit/core/test_bundle_row_scope.py::test_unrelated_rebuild_keeps_user_scope_owners_and_hashscope: projecttests/integration/test_user_scope_bundle_rows_lifecycle.py::test_project_bundle_rows_keep_project_scopetests/unit/core/test_bundle_row_scope.py::test_user_rows_stay_out_of_project_lookupstests/unit/core/test_bundle_row_scope.py::test_bundle_writer_requires_an_explicit_scopetests/unit/core/test_bundle_row_scope.py::test_supplied_provenance_carries_the_bundle_scopetests/unit/core/test_bundle_row_scope.py::test_ambiguous_claim_in_one_source_keeps_the_path_inferred_scopetests/unit/core/test_bundle_row_scope.py::test_prior_ledger_scope_wins_over_disagreeing_provenanceHow to test
apm install -g <packed-bundle> --target claude, thengrep -A3 'skills/<name>/SKILL.md' ~/.apm/apm.lock.yaml: expectscope: user.apm install -g <some-other-package> --target claude: the bundle rows are unchanged.~/.apm:apm install -g --frozen --target claudeandapm audit --ciboth pass.apm install <packed-bundle>: the rows sayscope: project.Issue and approved scope
Issue: Fixes #3995
Human scope-approval comment: #3995 (comment) (
eligibility.cjs:record-present, review contact Daniel Meppiel (@danielmeppiel)).This PR completes the issue's approved scope. The 0.37 known-issue release note is out of scope here.
Type of change
Testing
Changelog
## [Unreleased]inCHANGELOG.md(bottom ofFixed).Spec conformance (OpenAPM v0.1)
scopefield already exists.Co-authored-by: Copilot [email protected]