gnodet commented on code in PR #1815:
URL: https://github.com/apache/maven-resolver/pull/1815#discussion_r4781174283


##########
maven-resolver-util/src/main/java/org/eclipse/aether/util/graph/manager/TransitiveDependencyManager.java:
##########
@@ -140,30 +140,4 @@ protected DependencyManager newInstance(
                 managedExclusions,
                 systemDependencyScope);
     }
-
-    /**
-     * Controls inheritance-based property derivation for scope and optional 
properties.
-     * <p>
-     * <strong>Why scope and optional are special:</strong> In dependency 
graphs, these two properties
-     * are subject to inheritance during graph transformation (which is 
outside ModelBuilder's scope).
-     * Therefore, scope and optional are derived only from the root to prevent 
interference with
-     * inheritance logic.
-     * </p>
-     * <p>
-     * <strong>The inheritance problem:</strong> If we managed scope/optional 
from sources below the root,
-     * we would mark nodes as "managed" in the dependency graph. The "managed" 
flag means "do not touch it,
-     * it is as it should be", which would prevent proper inheritance 
application during later graph
-     * transformation, causing nodes to end up with incorrect scope or 
optional states.
-     * </p>
-     * <p>
-     * <strong>Special case:</strong> The "system" scope has special handling 
due to its unique path requirements.
-     * </p>
-     *
-     * @return true only at depth 0 (root level) to ensure inheritance-based 
properties are only
-     *         derived from the root, false otherwise
-     */
-    @Override
-    protected boolean isInheritedDerived() {
-        return depth == 0;
-    }
 }

Review Comment:
   _Claude Code on behalf of Guillaume Nodet_
   
   Note: `isInheritedDerived()` still exists on current master and is still 
called in `AbstractDependencyManager.deriveChildManager()`. The rebase will 
need to reconcile this removal with the current code — the 
`isInheritedDerived()` guard on master currently gates scope/optional 
collection.



##########
maven-resolver-api/src/main/java/org/eclipse/aether/collection/DependencyManagement.java:
##########
@@ -29,22 +31,46 @@
  * @see DependencyManager#manageDependency(org.eclipse.aether.graph.Dependency)
  */
 public final class DependencyManagement {
+    /**
+     * Enumeration of manageable attributes, attributes that can be subjected 
to dependency management.
+     *

Review Comment:
   _Claude Code on behalf of Guillaume Nodet_
   
   `@since 2.0.19` is stale — current master is at `2.0.25-SNAPSHOT`. This and 
all other `@since 2.0.19` annotations across the PR should be updated to 
`@since 2.0.25` after rebase.



##########
maven-resolver-util/src/main/java/org/eclipse/aether/util/graph/manager/AbstractDependencyManager.java:
##########
@@ -206,14 +207,23 @@ private boolean containsManagedVersion(Key key, MMap<Key, 
String> managedVersion
         return managedVersions != null && managedVersions.containsKey(key);
     }
 
-    private String getManagedVersion(Key key) {
+    /**
+     * Returns {@code true} if this manager represents the root level (factory 
or root POM level).
+     * Per the depth model: 0 = factory (seed), 1 = root (project POM), 2+ = 
descendants.
+     * Management entries from root level should be enforced, while those from 
descendants are advised.
+     */
+    private boolean isRootManager() {
+        return depth <= 1;
+    }
+
+    private AbstractDependencyManager getManagedVersion(Key key) {
         for (AbstractDependencyManager ancestor : path) {

Review Comment:
   _Claude Code on behalf of Guillaume Nodet_
   
   `isRootManager()` uses `depth <= 1` which covers both factory (depth 0) and 
root POM (depth 1). After the rebase, this helper is still the right 
abstraction — it just needs to be called at collection time (in 
`deriveChildManager`) rather than at lookup time, since the new `LayeredMap` 
architecture doesn't preserve per-entry depth information.



##########
maven-resolver-util/src/main/java/org/eclipse/aether/util/graph/manager/AbstractDependencyManager.java:
##########
@@ -227,14 +237,14 @@ private boolean containsManagedScope(Key key, MMap<Key, 
String> managedScopes) {
         return managedScopes != null && managedScopes.containsKey(key);

Review Comment:
   _Claude Code on behalf of Guillaume Nodet_
   
   🔴 **Architectural incompatibility with current master**
   
   This method now returns `AbstractDependencyManager` (the owner) instead of 
`String`, and iterates over `path` to find the owner. However, master has 
replaced the `path` field with `LayeredMap` cumulative maps — `ancestorScopes` 
now provides O(1) value lookup via `ancestorScopes.get(key)` but returns only 
the value, not a reference to which layer/depth provided it.
   
   The enforcement check `scopeOwner.isRootManager()` requires knowing the 
depth of the manager that stored the entry, which is information `LayeredMap` 
doesn't expose.
   
   **Suggested approach after rebase:** Compute the enforcement flag at storage 
time in `deriveChildManager()`, when the current depth is known. For example, 
use a value wrapper like:
   ```java
   record ManagedEntry<T>(T value, boolean enforced) {}
   ```
   or (for Java 8 baseline) a simple holder class. Then `getManagedScope(key)` 
can return the wrapper directly and `manageDependency()` reads the pre-computed 
enforcement flag.



##########
maven-resolver-util/src/test/java/org/eclipse/aether/util/graph/transformer/ConflictResolverTest.java:
##########
@@ -725,7 +805,7 @@ private static DependencyNode makeDependencyNode(String 
groupId, String artifact
     }
 
     private static DependencyNode makeDependencyNode(String groupId, String 
artifactId, String version, String scope) {
-        return makeDependencyNode(groupId, artifactId, version, null, 
"compile");
+        return makeDependencyNode(groupId, artifactId, version, null, scope);

Review Comment:
   _Claude Code on behalf of Guillaume Nodet_
   
   🐛 Pre-existing bug fix: this 4-arg overload was ignoring the `scope` 
parameter and always passing `"compile"`. The fix is correct. Consider noting 
it separately in the PR description for traceability, since it's unrelated to 
the advised/enforced feature.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to