Repository navigation
Report cyclic library dependencies as errors - #3236
akozhushko wants to merge 2 commits into
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
Conflicting self-dependencies can still cause infinite resolution loops, and the cycle regression can pass on an unavailable-library error without verifying successful resolution.
2 open issues
What changed in this PR
This PR addresses nonterminating library dependency resolution in 4diac IDE by clearing each node’s change flag after processing, allowing cycles with stable version constraints to finish.
Changes:
- Reset dependency-node state before processing.
- Mark nodes changed when their last dependency cause is removed.
- Add a watchdog-backed cycle regression test and register its fixtures.
| File | Description |
|---|---|
tests/org.eclipse.fordiac.ide.test.library/src/org/eclipse/fordiac/ide/test/library/LibraryTestFixtures.java |
Registers test08 and test09 archives. |
tests/org.eclipse.fordiac.ide.test.library/src/org/eclipse/fordiac/ide/test/library/LibraryDependencyCycleTest.java |
Adds an explicit-build cycle test with watchdog cancellation. |
plugins/org.eclipse.fordiac.ide.library/src/org/eclipse/fordiac/ide/library/LibraryManager.java |
Resets the change flag before processing each dependency node. |
plugins/org.eclipse.fordiac.ide.library/src/org/eclipse/fordiac/ide/library/DependencyNode.java |
Adds flag reset support and propagates removal of the last cause. |
Review effort: Balanced
c10d431 to
c753d79
Compare
There was a problem hiding this comment.
🟡 Changes recommended
The dependency-processing limit counts skipped duplicate queue entries, causing false cycle errors on acyclic graphs and potentially leaving transitive dependencies unresolved.
3 open issues
2 resolved since last review
Review effort: Balanced
| } | ||
|
|
||
| // import valid nodes | ||
| importDependencyNodes(project, libManagerData, projectManifest, markerList, progress.split(15)); |
There was a problem hiding this comment.
With the new fixture, this still links test10 1.0.0 after reporting that it requires itself at 2.0.0. Please skip importing the conflicting library and assert that it stays unlinked when force-loading is disabled.
| final boolean rangeChanged = recalculate(); | ||
| if (removed && causes.isEmpty()) { | ||
| // the node is not needed any more: it has to be visited again even if its range did not change | ||
| changed = true; |
There was a problem hiding this comment.
When a version change drops a dependency, LibraryManager calls removeCause at line 833 but never queues the changed node. Please enqueue it so its transitive dependencies can be removed too.
| @@ -0,0 +1,134 @@ | |||
| /******************************************************************************* | |||
| * Copyright (c) 2026 Andrii Kozhushko | |||
There was a problem hiding this comment.
I think the copyright here should be MSR , please clarify that who gets the copyright
There was a problem hiding this comment.
- Copyright (c) 2026 MSR Software GmbH
|
Instead of resolving cycles, I would report them as errors. A library that requires itself, or libraries that require each other (directly or transitively), should create an error marker whose message says what is wrong and which libraries are involved, e.g.:
Libraries of the cycle should not be linked. Please attach the marker like the other dependency markers in None of the standard libraries in Please adapt |
c753d79 to
976319c
Compare
|
Thanks for the review. I changed the PR as you suggested: cycles are now reported as errors instead of being resolved. Each cycle gets one error marker on the manifest that names the libraries and versions, and the libraries of a cycle are not linked. |
There was a problem hiding this comment.
🟡 Changes recommended
Critical unresolved defects can leave dependency resolution incomplete, repeatedly re-enqueue nodes, or loop indefinitely, while additional test, API-versioning, and attribution issues remain.
6 open issues
Preserve existing links when dependency resolution is incomplete · New Check the full graph-and-queue state on every iteration · New Reset the changed flag after processing each dependency node · New Make the build test cancellable to prevent watchdog hangs · New Bundle version is not advanced for the public API change Credit MSR Software GmbH in modified source notices · New
2 resolved since last review
Review effort: Lite
d21d6e2 to
8cd2033
Compare
There was a problem hiding this comment.
🟡 Changes recommended
Two critical dependency-resolution defects can retain dropped libraries and incorrectly skip unrelated libraries during cycle handling, so the change is not yet safe to merge.
7 open issues
Re-enqueue nodes when their last cause is removed · New Exclude unrelated nodes from cyclic libraries · New Reset the changed flag after processing each dependency node Test alternating version changes and cycle recovery · New Bundle version is not advanced for the public API change Bump the bundle version for the functionality addition · New Remove the updated copyright year range · New
4 resolved since last review
Review effort: Lite
| if (before != null) { | ||
| reportUnstable(data, new TreeSet<>(visited.subList(before.intValue(), visited.size()))); | ||
| return false; |
There was a problem hiding this comment.
Added in ace6135: testLibrariesWhoseVersionsSwitchEachOtherAreReported with test11/test12 in the versions 1.0.0 and 2.0.0. The build ends, the two libraries are reported and not linked, and test01 is still linked.
| @@ -1,5 +1,5 @@ | |||
| /******************************************************************************* | |||
| * Copyright (c) 2025, 2026 Primetals Technologies Austria GmbH | |||
| * Copyright (c) 2025, 2026 Primetals Technologies Austria GmbH, MSR Software GmbH | |||
There was a problem hiding this comment.
The range "2025, 2026" was in the notice before this pull request; this change only adds MSR Software GmbH and a contributor line.
The fixtures only extract the prepared test archives. A test for the resolution of library dependencies needs libraries that require each other in chosen versions, which would need a new archive for every graph. LibraryTestFixtures.createLibrary builds a library with the given symbolic name, version and requirements (symbolic name and version range) and extracts it into the workspace library folder. removeFixtureLibraries and hasFixtureLibraries take these libraries into account, so a test class that creates libraries leaves the workspace as it found it. No test uses it yet. Signed-off-by: Andrii Kozhushko <kozhushko378@gmail.com>
The dependency resolution never ended for libraries that require each other (a requires b, b requires a), for a library that requires itself, and for libraries whose versions select each other without end: the worklist of buildDependencies never became empty. Such libraries are now reported as an error marker on the dependencies of the project manifest and are not resolved or linked, also with the preference to force load the explicit dependencies. Existing links to them are removed. Messages: "Cyclic library dependency: a 1.0.0 -> b 1.0.0 -> a 1.0.0.", "Library a 1.0.0 requires itself (version 2.0.0)." and, for versions that select each other, "The versions of the libraries a, b could not be resolved consistently because their requirements depend on each other.". A cycle of overlapping cycles names the other involved libraries. How it works: - After the queue is empty, the requirements of the resolved versions form a graph. Its cycles are blocked, but only the cycles that no other cycle leads to, so that libraries behind a cycle are not reported as well. - The queue holds each library once, a library is visited when its range or its need changed, and the changed flag is reset when it is visited. - A repeated state (libraries, requirements and ranges) is looked up only for libraries that were visited before. It means that the greedy choice of the highest versions oscillates. The libraries of the period that lie on a cycle of the requirements seen during the period are blocked, other libraries are not affected. The state is only built for repeated visits and the recorded states are dropped when something is blocked. - A dependency that a new version of a library no longer requires is queued, so that its own requirements are removed as well, and a library that is not needed any more is removed when it is visited. - A conflict (empty version range) of a blocked library keeps its marker. The cause named "Project" is not dropped by a library of that name. - The resolution checks for cancellation in its loop. Graphs without a cycle are resolved as before. The resolution is still greedy: it does not search other versions, so a cycle or an oscillation can be reported although another choice of versions would avoid it, and a cycle next to a library that cannot be resolved can stay linked if the resolution stops early. LibraryDependencyCycleTest creates the libraries with LibraryTestFixtures.createLibrary. It covers direct, transitive, overlapping and self-requiring cycles, cycles behind a cycle, versions that select each other, a library that is not blocked beside a blocked one, conflicts, the order of the project requirements, force loading, removal of existing links and termination of resolutions that ended in an endless loop before. A timeout and a cancelled build make the tests fail instead of hang. Related issue: eclipse-4diac#2978. Signed-off-by: Andrii Kozhushko <kozhushko378@gmail.com>
5be2497 to
dcf4a0b
Compare
There was a problem hiding this comment.
🔵 Needs a closer look
The stateful dependency-resolver rewrite adds worklists, historical traces, cycle blocking, and asynchronous discovery whose termination and cleanup behavior cannot be fully validated statically, especially without the Eclipse integration and regression suites.
2 open issues
5 resolved since last review
Review effort: Lite



Dependency resolution did not end when libraries require each other (a requires b, b requires a), when a library requires itself, or when the versions of libraries select each other without end. The worklist of
buildDependenciesnever became empty and the build job kept running.As suggested in the review, such libraries are now reported as errors instead of being resolved. The marker is attached to the dependencies of the project manifest like the other dependency markers in
LibraryMarkerFactory:Cyclic library dependency: a 1.0.0 -> b 1.0.0 -> a 1.0.0.(other libraries of overlapping cycles are listed as "Also involved")Library a 1.0.0 requires itself (version 2.0.0).The versions of the libraries a, b could not be resolved consistently because their requirements depend on each other.The libraries of a cycle are not resolved and not linked, also with the preference to force load the explicit dependencies, and existing links to them are removed. Other libraries are resolved as before.
Changes in the resolution loop (details in the commit message):
changedflag of a dependency node is reset when it is visited.On 968 random graphs without a cycle the result equals the original, except one graph with one additional download of a library that is not needed.
LibraryDependencyCycleTest(31 tests, libraries created with the newLibraryTestFixtures.createLibrary) checks the messages, that the libraries are not linked, removal of existing links, conflicts, the order of the project requirements and termination. A timeout and a cancelled build make a test fail instead of hanging. It also fails for 13 deliberately broken variants of the resolution.Limitations:
Projectstill replaces the cause of the project in a shared dependency, as before.Related issue: #2978.