Repository navigation
fix: bound dependency-module imports to what the open file needs (v0.14.1) - #115
Merged
Merged
Conversation
…14.1) v0.14.0 imported every in-repo GA that any pom reported missing. Each import surfaced the next layer of the transitive closure (60 modules, 3.1 GB RSS and 30 s timeouts on products), and ClasspathRefresher sent refreshDiagnostics after every ClasspathUpdated event into a busy jdtls. Imports now run in bounded rounds that only fresh demand can start: - demand = an open .java file with #110-class errors (problem ids, with a bounded message fallback), confirmed by a refreshDiagnostics publish that lands between the send and the response and matches the document digest, sent after build-idle (language/progressReport, 10 s quiet, indexing tasks ignored); - candidates = frontier (in-repo <dependencies> of the demand module and of imported modules, with the in-repo parent chain; test/test-jar edges only for src/test demand) intersected with m2e Missing-artifact markers; declaration order, hubs last; at most 8 per round, sent as one didChangeWorkspaceFolders; - fixed STOP reasons (clean, no-candidates(none|markers-pending| owner-has-jar), budget, rounds, wall-clock, jdtls-busy, no-fresh-diagnostics), logged and sent once via window/logMessage; - budget 30 and 6 rounds (repo config can only lower, env can raise to 200/20), a 5-minute wall clock from the round-1 import, and 3 refreshes per round, one in flight, with one retry. The per-ClasspathUpdated refresh is removed in the same change. The reactor index gains dependency edges, the parent chain and fan-in, and markers keep type/classifier (test-jar). The data-dir key is tagged ws2, and the proxy keeps its own record of imported modules. jdtls 1.61 drops added folders on restart, so the record resets. Shutdown: real SHUTDOWN/EXIT handlers and SIGTERM/SIGHUP handlers stop jdtls within ~3 s (shutdown reply read first, SIGTERM after 1 s, SIGKILL after 2 s) and end the process with os._exit, so no JVM outlives the server (#107). pygls>=2.0. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A round now refreshes the files that had fresh demand in that round (still open, most recent first, at most 3), instead of whichever open files looked like demand from their latest publish. When jdtls re-validated a file on its own mid-build, the round was otherwise decided without a refresh. The e2e test asserts that the post-idle refresh ran and saw the clean set. With the refresh disabled, both dependency e2e tests fail. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The 5-minute cap started at the session's first import and never reset. A module armed 20 minutes after the first one stopped clean was cut off with wall-clock as soon as it had candidates. Now only import phases count (round-1 import to STOP, minus refreshes after that import), and the total carries across re-arms. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- reactor: parse truncated "Missing artifact g:a:jar" markers without raising; proxy guards the dependency-module bookkeeping so it cannot kill the reader loop - refresh cap: a terminal refresh-cap STOP (not no-fresh-diagnostics), and a default cap of 3 x (rounds + 1) x 2 so the rounds limit fires first - probe-time jdtls-busy / no-fresh-diagnostics and failing phases un-arm their modules; a failing phase no longer drops queued modules; a repeated warning stop is logged at DEBUG only; nothing stays armed when no runner is scheduled - one phase per reactor root; refresh time on the STOP and summary lines - remove the unused "disabled" stop reason - signal watchdog exits without logging.shutdown(); record temp file via NamedTemporaryFile; capped repo-config log value and open progress ids - tests: budget cut-off inside a round, demand during a phase, the extra quiet window, failing phases, JSON-RPC error and cancelled requests, real server process shutdown/exit codes Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… ms sleep The test flaked on the macOS / Python 3.11 CI runner: the debounced analysis could run after the patch context exited, so the file was still pending. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
aviadshiber
marked this pull request as ready for review
September 30, 2026 08:00
aviadshiber
added a commit
that referenced
this pull request
Sep 30, 2026
…n its own (v0.14.2) (#117) * fix: resume a busy dependency-module round and give jdtls time to save on stop (v0.14.2) Follow-ups from the v0.14.1 products-gate evidence (#115): 1. A large module group's jdtls build routinely outlasts the fixed 90 s round timeout (measured: a 95-module/127-project service/boot group never went idle within 90 s across three gate runs, t2/t2b/t2c). The old code treated a busy timeout as a dead end: it stopped with jdtls-busy and un-armed the module, so only a new demand publish (which jdtls never sends without a fresh classpath change) could try again. _wait_idle() now retries the wait for build-idle within a bounded busy budget (up to 6 attempts, 10 minutes) instead of failing at the first 90 s timeout, so the round resumes as soon as jdtls next reports idle. The session's existing budget/rounds/wall-clock limits are still checked between attempts, and a final jdtls-busy STOP (which still un-arms the module) only fires once the busy budget itself is exhausted. 2. Mid-import shutdown: stop() gave the JVM only ~1 s after the exit notification before SIGTERM, shared with the shutdown-request timeout. Research (Eclipse bug 272648 and related Eclipse Platform/JDT-LS reports) confirms "the workspace exited with unsaved changes" comes from an incomplete ResourcesPlugin SaveManager .snap write, which SIGTERM mid-save can produce. A dedicated exit-grace constant now bounds the JVM's own post-exit save-and-exit (3 seconds), decoupled from the shutdown reply timeout. Total worst-case stop bound: about 6 seconds (shutdown reply + exit grace + SIGTERM wait + SIGKILL wait); the cooperative path is unaffected (well under 1 second). The exact real-jdtls mid-import exit duration was not measured (too costly for this change, deferred); the exit-grace budget is a reasoned estimate, stated in the code comment. 3. Added the missing proxy test: note_publish and idle.note_progress raising is caught and logged, and the next message of each kind is still handled (diagnostics cache updated / BuildIdle updated). 4. The round-log line now states the order explicitly (imported, then idle, then refresh), instead of reading as if the import happened after going clean. 5. Investigated tests/test_diagnostics_freshness.py's fixed-sleep helpers (_past_debounce, _past_min_age): every use is already followed by the bounded _until() poll (the prior CI-flake fix already covers this); no further fixed-sleep-then-assert instances were found there or elsewhere in tests/. Fail-before: the busy-round-resume test and the slow-to-save shutdown test were both run against a detached origin/main worktree and shown to fail there (a final busy stop, and a SIGTERM mid-save respectively), then the scratch worktree was removed. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> * fix: latch the real session-limit reason through a busy retry (PR #117) _wait_idle's busy-retry loop returned a bare busy timeout even when a session limit (budget/rounds/wall-clock) had already been reached mid-retry, instead of latching self._session.terminal like _select does. Since the generic jdtls-busy reason is retryable, the module was un-armed and its next demand re-entered the same limited session and busy-waited again, repeating indefinitely on a persistently busy jdtls -- exactly the large-module-group scenario this PR targets. _wait_idle now returns the real STOP reason (or None on idle) and latches it onto the session before the busy-retry exhaustion check, so a terminal limit is never masked as jdtls-busy even on the final retry attempt, and _process/_round log and report the true reason. Adds two tests covering previously-untested _wait_idle paths (the busy_wait_budget deadline, and a session limit reached mid-retry) plus a third for the limit-vs-exhaustion race on the final attempt; each was verified to fail against a hand-mutated pre-fix reproduction. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> --------- Co-authored-by: Aviad Shiber <aviad.s@taboola.com> Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
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.
Why
v0.14.0 (#110, #114) imported every in-repo GA that m2e reported missing on any pom. Each import exposed the next layer of the transitive closure. On products (
delta-product-config-report), the import cascaded to the 60-module budget (viper-*,spark-*,trs-*, ...):refreshDiagnosticstimeouts, becauseClasspathRefresherrefreshed after every ClasspathUpdated event into a busy jdtls.Experiment S2 showed the file needs 4 modules, each proven necessary by ablation: taz-kfc-core, mario-hdfs-connector, traffic-analyzer-backend and frontend-data-consumer-core. It also showed that jdtls never re-publishes an open file after an import, so a refresh after build-idle is required.
Design:
java-functional-lsp-dependency-module-cascade.md, "Final design v2.1" as amended by "v2.2". Items deferred to v0.15 are not in this PR.Change
Demand-driven rounds (
dependency_modules.py):.javafile with False 'cannot be resolved' / 'hierarchy is inconsistent' for inherited symbols when a module is treated as a non-project file #110-class errors. The problem ids are checked first, with a bounded message fallback. Build-path markers (0,964) and non-project files (16) are excluded.language/progressReportviaextendedClientCapabilities.progressReportProvider=true, no open non-indexing task, and 10 s without a progress event. There is a single timer, and "Searching…"/indexing tasks are ignored.java.project.refreshDiagnosticsfor the round's demand files: most recently opened first, at most 3, one in flight, a 20 s timeout and one retry.<dependencies>of the demand module and of every imported module, including the in-repo parent chain. For asrc/testfile, the demand module's test andtest-jaredges are added. Deferred candidates carry forward.test-jaredge only matches atest-jar/testsmarker. They are ordered by declaration, hubs last. At most 8 go into onedidChangeWorkspaceFoldersper round.clean,no-candidates(none|markers-pending|owner-has-jar),budget,rounds,wall-clock,jdtls-busy,no-fresh-diagnostics. Each STOP is logged, and sent once viawindow/logMessage. A new module re-arms the process unless a session limit was hit.JAVA_FUNCTIONAL_LSP_DEPENDENCY_MODULESand the newJAVA_FUNCTIONAL_LSP_DEPENDENCY_ROUNDScan raise them up to 200 and 20;Reactor index (
reactor.py): dependency edges (scope, test-jar),${project.groupId}/${project.parent.groupId}substitution, and the parent GA of each module. A GA→dir map (aggregators included) serves parent lookups, with a visited set and a depth bound. The index also records fan-in. The hardened parser rules are unchanged, anddependencyManagementis ignored.Hygiene (
proxy.py,server.py):ws2|, so the bloated v0.14.0 workspaces are not reused. LRU eviction reclaims them and their.deps.json.<hash>.deps.json). It resets at each start, because jdtls 1.61 drops the added folders on restart (pre-check 1).SHUTDOWN/EXIThandlers. The EXIT handler awaits a boundedproxy.stop(), then callsos._exit.stop()reads the shutdown reply before cancelling the reader. It sends SIGTERM after 1 s and SIGKILL after 2 s, and it is idempotent. This fixes the orphaned JVM (Scoped jdtls import leaves src/main/java off the classpath in large Maven monorepo, findReferences returns nothing #107).pygls>=2.0. Version 0.14.1.Testing
Pre-checks (real jdtls 1.61):
didChangeWorkspaceFolders, then jdtls was shut down and restarted on the same data dir.java.project.getAllafter build-idle listed onlygroupB/it, and all 4 import errors were back. The folders do not persist, so the record resets at start.language/progressReportshape matches the design (id, task, subTask, status, workDone, totalWork, complete). Every id completes in runs A–G, and "Searching..." is the dominant indexing task. In runs B, C, E, F and G the refresh publish arrives just before thenullresponse.New e2e tests (real jdtls, isolated primed repository, never
~/.m2):test_parent_inherited_chain_stops_when_clean. App → mid; mid's parent pom declares owner; owner → deeper, which the file does not need.test_cross_group_dependency_resolves. The post-idle refresh must run and see the clean set.test_sigterm_leaves_no_jdtls. SIGTERM the server, then check the JVM pid.mid, owner, deeper(the cascade){mid}, round 2{owner}(inherited via the parent), STOP clean, 2/30 modules,deepernever importedThe behavioral evidence for the post-idle refresh is an ablation: with the round refresh disabled, both (a) and (b) fail. In (a) the file keeps "The import com.example.mid cannot be resolved" because jdtls does not re-publish it after round 1. In (b) the STOP line shows
refreshes 1.Unit tests cover:
no-candidatesdetails;jdtls-busy);ws2key, and theprogressReportProvidermerge;stop()against real child processes: a cooperative one under 1 s, SIGTERM, SIGKILL in under 3.5 s, and idempotence;Gates:
ruff check,ruff format --check,mypy srcandpytest -qall pass: 1062 passed, 1 skipped (the pre-existing measurement-only test), 89.45% coverage. All real-jdtls e2e tests ran.Not in this PR / notes:
claude -pondelta-product-config-report) was not run here.disabledis in the STOP enum, but a disabled budget is logged once at start and never runs a round.app, nottarget: jdtls excludes**/target/**from the import.🤖 Generated with Claude Code