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
[0.38] fix(deps): install --frozen accepts one local lib reached by two relative paths (#4731) - #4739
apm install --frozen refused a lockfile that apm install had just written when a monorepo reached one local library through two relative paths (./packages/lib-05 from the root, ../lib-05 from a sibling package). Install wrote two lock rows for that one directory (./packages/lib-05 and local:packages/lib-05), both carrying _local/lib-05. The frozen replay then found two resolved_by parent candidates and raised ambiguous resolved_by parent, and apm audit --ci failed skill-subset-consistency on the duplicate row.
One anchored directory is now one dependency, decided at the owner:
src/apm_cli/deps/local_identity.py (new owner): root_local_dirs() / transitive_local_identity(), called by the resolver. A local edge that a package declares, whose anchored directory the root manifest also declares, takes the root declaration's identity and spelling. Install therefore writes ONE lock row; the sibling edge links to the root node. Other transitive local edges keep their anchored local: identity.
src/apm_cli/install/local_content_verdict.py (the --frozen / audit --ci local-content verdict) and src/apm_cli/deps/reachability.py (the declared-graph walk behind audit --ci, uninstall and prune) now route through the same owner helpers instead of re-deriving the anchored identity, so they attribute both declaring edges to that one row.
The collapsed node keeps install semantics: production status reaches every descendant of a production node (a root devDependency that a production sibling needs ships its subtree), and a targeted update rechecks an existing node at its own anchor.
Guard: contracts-tooling-local-identity (closed world, with a mutation case) refuses any other code that derives an anchored local identity, and requires the three consumers to call the owner.
src/apm_cli/deps/path_anchoring.py: for lockfiles written before this fix (two rows), parent candidates that anchor to the SAME directory are one parent. Candidates in DIFFERENT directories still refuse with ambiguous resolved_by parent.
The lockfile schema is unchanged. A legacy two-row lockfile replays under --frozen with its bytes unchanged (verified on the installed CLI); audit --ci and distinct per-edge selections point to apm install, which rewrites it to one row. The residual reported earlier on this PR ("two lock rows for one directory / audit skill-subset red") is fixed in this PR, so no separate bug is needed.
Follow-up, not in this PR: apm uninstall <direct dep> drops a direct dependency's lock row even when another package still needs it transitively. This already happens on main for remote packages (root declares d and e, d depends on e, apm uninstall e, then install --frozen fails "does not record everything this install deploys"). It now applies equally to a root-declared local library a sibling also reaches. Reported to the lead for its own record.
This PR completes the issue. Out of scope per the record: lockfile format changes (none: same schema, one row per anchored directory), containment or path-anchoring rules (unchanged), non-local dependencies.
Type of change
Bug fix
New feature
Documentation
Maintenance / refactor
Testing
Tested locally
All existing tests pass
Added tests for new functionality (if applicable)
promise: P-INV-I3 -- install --frozen and audit --ci accept the lockfile install just wrote, without changing it (source: #4731 scope record)
cell: OP=install FROZEN=on SRC=local(transitive, two spellings) PRIM=skill SCOPE=project owner: deps/apm_resolver.py (local identity)
instrument: today test -> tests/integration/test_local_monorepo_frozen_replay_lifecycle.py::test_frozen_replays_a_lib_reached_by_two_relative_spellings (new: no monorepo two-spelling cell existed)
oracles: [I1 one lock row per directory, I3 frozen + audit --ci exit 0, lockfile bytes unchanged, deployed snapshot unchanged]
failing-before (main 899d17b4): install --frozen exit 1 "ambiguous resolved_by parent '_local/lib-05' ... (['../lib-05', './packages/lib-05'])"; with only the path_anchoring tolerance, audit --ci exit 1 "skill-subset-consistency: local:packages/lib-05: selection unverified"
passing-after: 1 passed
ledger: tests/fixtures/lifecycle_bug_ledger/bugs/4731.json
hints executed: none printed on success
Owner unit cases (tests/unit/deps/test_apm_resolver_helpers.py, TestOneAnchoredDirectoryIsOneDependency and TestOneAnchoredDirectoryNode):
the root spelling wins for the same directory, and another directory keeps its local: identity;
legacy two-row parents in one directory resolve as one parent;
parents in different directories still refuse (control);
a dev root library needed by a production sibling, and its descendants, are production (failed before);
a targeted sibling update rechecks the library at its own anchor (failed before).
Conformance: tests/spec_conformance/test_local_path_identity_reqs.py cites req-mf-016 (./ and ../ entries are local-path entries), which flips req-mf-016 from skipped to active in CONFORMANCE.
Head 26cbdec: lifecycle test, owner unit cases, conformance and quality baselines: 204 passed, 1 skipped. Head cd99d2e (review follow-ups): owner unit cases 47 passed, architecture rule inventory + mutation cases 22 passed; full neighbour run delegated to PR CI and ci-integration.
Lint chain clean: ruff check and format (0.15.12), pylint R0801, lint-auth-signals, complexity ratchet, assertion-quality ratchet, tm006 taxonomy, architecture boundaries, Mode B (req cited, no waiver).
Changelog
One fragment per section, changelog.d/<pr>.<section>.md.
…ambiguous (#4731)
install --frozen refused a lockfile where ./packages/lib-05 (root) and
../lib-05 (sibling) both carry _local/lib-05. Resolve every parent
candidate and refuse only when they anchor to different directories.
Adds a failing-before installed-CLI lifecycle test and an owner unit case.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
This reverts commit 6ad79c0. The fix now cites req-mf-016 through a
conformance marker, so Mode B passes without a waiver.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
A sibling's ../lib edge to a directory the root manifest declares as
./packages/lib now takes the root declaration's identity, so install
writes one lock row. The resolver owns the rule
(transitive_local_identity); the --frozen local-content verdict and the
reachability walk behind audit --ci route through it. Cites req-mf-016.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Restores the strict audit oracle relaxed in 6fbef8e: with one lock row
per anchored directory the skill-subset check passes.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
The reason will be displayed to describe this comment to others. Learn more.
🟢 Approval recommended
There are no active review issues blocking approval of the frozen-install path-resolution change.
No open issues 🎉
What changed in this PR
Fixes #4731 by allowing frozen installs to replay monorepo lockfiles when different relative paths identify the same local library, without changing the lockfile format or path-containment rules.
Changes:
Resolves all local parent candidates and accepts them when they anchor to one directory; distinct directories remain ambiguous.
Adds unit and installed-CLI regression coverage for frozen replay, unchanged lockfile and deployed files, and audit parent resolution.
Adds a user-facing changelog fragment.
File
Description
tests/unit/deps/test_path_anchoring.py
Tests equivalent parent paths and rejection of distinct directories; updates the helper mock.
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
Production status fails to propagate to transitive dependencies, causing both plugin exporters to omit required content, while legacy frozen replay and targeted sibling updates also remain broken.
…d its owner (#4731)
- Production status now reaches every descendant of a production node, so a
root devDependency that a production sibling also needs ships its subtree.
- A targeted update rechecks an existing node at its own reference and parent,
not at the incoming edge's anchor.
- deps/local_identity.py owns the local node identity; the resolver, the
--frozen verdict and the reachability walk call it, and the new
contracts-tooling-local-identity guard (with a mutation case) refuses bypasses.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
Two critical issues remain: production propagation can leave shared dependencies dev-only based on declaration order, and canonicalized rescue paths can cause uninstall to persist an incorrect parent-relative lockfile path.
Canonicalizing ref.local_path also changes the parent-relative path returned in reachable_via, which uninstall persists during orphan rescue. With a legacy two-row lockfile, production roots a and b both declaring ../lib, and a dev root declaring ./packages/lib, uninstalling a repairs the rescued row to ('_local/b', './packages/lib'), incorrectly pointing at packages/b/packages/lib. Preserve the original declaring path for repair data while using the canonical reference for identity and selections, and add a legacy rescue regression.
Propagation now also walks edges the queue dedup dropped (recorded in
_edge_parents), so a leaf shared by two dev roots is production once a
production edge reaches one of them, in either declaration order.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
Human assessment is needed because symlink canonicalization can cause queue deduplication to bypass the explicit single-file symlink refusal, accepting a dependency edge previously rejected.
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
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
apm install --frozenrefused a lockfile thatapm installhad just written when a monorepo reached one local library through two relative paths (./packages/lib-05from the root,../lib-05from a sibling package). Install wrote two lock rows for that one directory (./packages/lib-05andlocal:packages/lib-05), both carrying_local/lib-05. The frozen replay then found tworesolved_byparent candidates and raisedambiguous resolved_by parent, andapm audit --cifailedskill-subset-consistencyon the duplicate row.One anchored directory is now one dependency, decided at the owner:
src/apm_cli/deps/local_identity.py(new owner):root_local_dirs()/transitive_local_identity(), called by the resolver. A local edge that a package declares, whose anchored directory the root manifest also declares, takes the root declaration's identity and spelling. Install therefore writes ONE lock row; the sibling edge links to the root node. Other transitive local edges keep their anchoredlocal:identity.src/apm_cli/install/local_content_verdict.py(the--frozen/audit --cilocal-content verdict) andsrc/apm_cli/deps/reachability.py(the declared-graph walk behindaudit --ci,uninstallandprune) now route through the same owner helpers instead of re-deriving the anchored identity, so they attribute both declaring edges to that one row.contracts-tooling-local-identity(closed world, with a mutation case) refuses any other code that derives an anchored local identity, and requires the three consumers to call the owner.src/apm_cli/deps/path_anchoring.py: for lockfiles written before this fix (two rows), parent candidates that anchor to the SAME directory are one parent. Candidates in DIFFERENT directories still refuse withambiguous resolved_by parent.The lockfile schema is unchanged. A legacy two-row lockfile replays under
--frozenwith its bytes unchanged (verified on the installed CLI);audit --ciand distinct per-edge selections point toapm install, which rewrites it to one row. The residual reported earlier on this PR ("two lock rows for one directory / audit skill-subset red") is fixed in this PR, so no separate bug is needed.Follow-up, not in this PR:
apm uninstall <direct dep>drops a direct dependency's lock row even when another package still needs it transitively. This already happens on main for remote packages (root declaresdande,ddepends one,apm uninstall e, theninstall --frozenfails "does not record everything this install deploys"). It now applies equally to a root-declared local library a sibling also reaches. Reported to the lead for its own record.Issue and approved scope
Issue: Fixes #4731
Human scope-approval comment: the
apm-scope:v1record on #4731 (review contact Daniel Meppiel (@danielmeppiel)).This PR completes the issue. Out of scope per the record: lockfile format changes (none: same schema, one row per anchored directory), containment or path-anchoring rules (unchanged), non-local dependencies.
Type of change
Testing
Owner unit cases (
tests/unit/deps/test_apm_resolver_helpers.py,TestOneAnchoredDirectoryIsOneDependencyandTestOneAnchoredDirectoryNode):local:identity;Conformance:
tests/spec_conformance/test_local_path_identity_reqs.pycites req-mf-016 (./and../entries are local-path entries), which flips req-mf-016 from skipped to active in CONFORMANCE.Local validation (through the host guard):
Changelog
changelog.d/<pr>.<section>.md.Spec conformance (OpenAPM v0.1)
No normative requirement changes. req-mf-016 gains a behavioral conformance test (now active in CONFORMANCE).