Skip to content

fix: bound jdtls group scope by the repo root and log m2e import errors (#110 part A) - #113

Merged
aviadshiber merged 2 commits into
mainfrom
fix/110-part-a-scope-and-logging
Sep 29, 2026
Merged

aviadshiber merged 2 commits into
mainfrom
fix/110-part-a-scope-and-logging

Conversation

@aviadshiber

Copy link
Copy Markdown
Owner

Why

Issue #110 reports false "X cannot be resolved" and "The hierarchy of the type X is inconsistent" errors on classes that live in another Maven group of the same repository. The investigation found two problems that can be fixed now. The full fix comes in a follow-up (part B).

  • The scope can blow up to the whole reactor (M2). The group-root walk stopped at the client's rootUri. When the client root sits above the repository (for example ~/git, which we saw in real session logs), the repository's own aggregator pom became a candidate. _find_maven_group_root(products/achilles-testing, ~/git) returned products, the whole 1248-pom reactor. With products as the root, it returned the module itself.
  • Import failures were invisible (M3). _handle_notification dropped window/logMessage and language/status. A jdtls spike (1.61.0, m2e 2.7.800) showed that m2e's Missing artifact g:a:t:v signal arrives only as Error diagnostics on the dependent module's pom.xml. server.py filters those out because it only handles .java files, so nobody ever saw them.

Change

  • F2: repository boundary. _find_maven_group_root now stops at the repository/reactor boundary: the nearest ancestor containing .git (a directory, or a file for worktrees and submodules). If there is no .git ancestor, it stops at the topmost ancestor reached through consecutive pom.xml directories. If the client root is below the boundary, the client root stays the bound. A module directly under the reactor root is scoped to itself, never to the whole reactor. The new _find_repo_boundary is lru_cached on the resolved path, so a symlinked path and its real path share one cache entry. expand_full_workspace logs the client root, boundary and group root once at INFO, with paths redacted. add_module_if_new logs the same at DEBUG.
  • F3: forward jdtls logs.
    • window/logMessage type 1 is logged at WARNING and type 2 at INFO. language/status Error is logged at INFO. Everything else goes to DEBUG.
    • Every message uses the fixed format "jdtls[%s]: %s", so message text is never used as a format string.
    • Text is sanitized before logging: URL userinfo, token/key/secret/password/auth/sig query params and Authorization/Bearer values are redacted. CR/LF are escaped, other C0/C1 control characters (including ESC) are stripped, and messages are cut at 2 KB.
    • Each message kind has its own token bucket (20 per 10 s). Identical messages inside the window are dropped, and a periodic suppressed N jdtls log messages line reports how many were dropped.
  • pom.xml diagnostics summary. When the set of Error diagnostics on a pom.xml URI changes, the proxy logs one sanitized INFO line: the pom path relative to the client root, the error count, and the first 3 messages. The hook lives in the proxy. What is published to the client does not change.
  • The version is bumped to 0.13.1, and the README has a new troubleshooting row that points at the new log lines.
  • scripts/generate-formula.py got a ruff-format fix (one blank line), and pyproject.toml got a "scripts/*.py" = ["T20", "PLR2004"] per-file ignore. Both are needed because uv run ruff check . and ruff format --check . already fail on main for this script (3 lint errors and 1 file to reformat). The gate below cannot pass without them.

Testing

  • uv run ruff check .: passed
  • uv run ruff format --check .: passed
  • uv run mypy src: passed
  • uv run pytest -q: 891 passed, 1 skipped (the existing measurement-only test_e2e_cross_file H2 case), 88.46% coverage. jdtls is installed locally, so the e2e tests ran.
  • New tests/test_proxy_scope_logging.py:
    • Scope cases: client root above, at and below the repository; module directly under the reactor root; no .git (topmost consecutive pom); .git as a file; symlinked paths; the scope logged once at INFO.
    • Sanitizer and forwarder cases: redaction, control characters, truncation, levels, literal format characters, dedupe, token bucket and refill, suppressed-count line.
    • pom diagnostics cases: logged only when the set changes, publishing unchanged, .java files not summarized, poms outside the client root redacted.
  • Existing group-expansion tests in tests/test_proxy.py now create a .git at the monorepo root, which is the repository boundary.

Refs #110

🤖 Generated with Claude Code

…rs (#110 part A)

F2: _find_maven_group_root now stops at the repository/reactor boundary
(nearest .git ancestor, else the topmost consecutive-pom ancestor), or at
the client root when that is below the boundary. A client root above the
repository (e.g. ~/git) can no longer scope jdtls to the whole reactor.
The client root / boundary / group root are logged once at INFO.

F3: forward jdtls window/logMessage (Error -> WARNING, Warning -> INFO) and
language/status (Error -> INFO) to the proxy log, sanitized (URL userinfo,
secret query params, Authorization/Bearer values, CR/LF, control chars,
2 KB cap), token-bucket rate limited per kind with in-window dedupe and a
periodic suppressed-count line. Log a one-line summary whenever the Error
diagnostics set of a pom.xml changes (m2e "Missing artifact" markers).
Nothing published to the client changes.

Also: version 0.13.1, README troubleshooting row, and ruff format/ignores
for scripts/generate-formula.py so the ruff gate passes.

Refs #110

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Query-param and URL-userinfo redaction regexes were superlinear on
  hostile jdtls text (cubic for "?token" repeated); they run on the
  reader loop. The userinfo run now anchors on "://", query names are
  bounded, and the secret keyword is checked in a callback.
- logMessage/language/status kinds come from an allowlist; unknown
  values log as "other", so jdtls text never reaches the log line
  unsanitized and the rate-limit buckets stay bounded.
- Flush the suppressed-message count when jdtls dies, not only on stop().

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@aviadshiber
aviadshiber marked this pull request as ready for review September 29, 2026 13:07
@aviadshiber
aviadshiber merged commit 4bbd8fe into main Sep 29, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants