Repository navigation
feat: fresh jdtls diagnostics in Claude Code's own tool result (#109 part B) - #112
Merged
Merged
Conversation
…part B) Claude Code attaches LSP diagnostics right after its PostToolUse hooks finish (measured: 141/141 attachments), without waiting for the server, so jdtls's result for an edit only showed up one tool call later. - The server stamps a per-file marker (timestamp only, private per-user temp dir, path hashed, symlink-safe) whenever it publishes final diagnostics for a Claude Code client; hooks/post_tool_lint.py waits until the stamp is newer than the edit (JAVA_FUNCTIONAL_LSP_HOOK_WAIT, default 3s, max 4s, bounded by the hook's own 5s cap). - After a Claude Code edit whose buffer matches the file on disk the server forwards a didSave to jdtls. Without it jdtls re-checked dependents against the old file and left them stale (~2/5 runs; cross-file constructor arity). - E2E through the real server + jdtls: the hook returns only after jdtls's new error is published (fails with HOOK_WAIT=0), and three arity cycles converge without a client didSave (fails on the first cycle without it). - Version 0.13.0, plugin 0.4.4. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Markers carry the server pid and a hash of the analyzed content instead of a time: a publish for an older version (late jdtls result, coarse mtime) can no longer release the hook, and the hook skips waiting when the server is gone. - Stamp only final publishes of files opened or edited since the last marker; off-mode debounce publishes and background republishes no longer stamp. didOpen writes a placeholder so the hook waits for jdtls's first result. - Hook reads markers safely: private owned dirs (no group/other bits), no symlinks (O_NOFOLLOW), regular file, bounded read; a marker problem never suppresses the lint output. Named wait constants. - Server: permissions tightened on existing marker dirs, 0600 temp file with O_NOFOLLOW, directory checks cached, getpass fallback to the uid. - didSave check: regular files only, never raises (runs after the hold task is scheduled), debug log on content mismatch, JAVA_FUNCTIONAL_LSP_AGENT_DIDSAVE=off kill switch; jdtls's handleSaved only reloads from disk (comment). - _AGENT_HOST_CLIENTS / _is_agent_host replace the hold-mode constant reuse. - Tests: in-process hook wait tests (budget, dead pid, placeholder, malformed and symlinked markers), agent-host marker rules, didSave edge cases, e2e with private TMPDIR, pinned modes, hold-all cross-file smoke test. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
kill(0, 0) and kill(-n, 0) signal process groups and usually succeed, so such a marker would look like a live server and make the hook wait its full budget. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
aviadshiber
marked this pull request as ready for review
September 28, 2026 11:56
aviadshiber
changed the base branch from
fix/109-stale-jdtls-diagnostics
to
main
September 28, 2026 11:58
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.
Part B of #109: get fresh jdtls diagnostics into the tool result of the edit that caused them, and fix the cross-file variant. Stacked on #111 (base branch
fix/109-stale-jdtls-diagnostics); merge #111 first.Why
Change
<pid> <sha256 of the analyzed content>to$TMPDIR/java-functional-lsp-<user>/fresh/<hash of path>(0700 dirs, 0600 file, symlink/ownership checks). didOpen writes a placeholder so the hook waits for jdtls's first result.hooks/post_tool_lint.pywaits until the marker's hash matches the file on disk, at mostJAVA_FUNCTIONAL_LSP_HOOK_WAITseconds (default 3, max 4, always under the hook's 5s cap). No marker or a dead server pid: no wait. The hook reads markers with O_NOFOLLOW from private owned dirs; a marker problem never suppresses the lint output.JAVA_FUNCTIONAL_LSP_AGENT_DIDSAVE=off.Testing
uv run pytest: 856 passed, 1 skipped (opt-in measurement), jdtls 1.61.0 locally.JAVA_FUNCTIONAL_LSP_HOOK_WAIT=0); three cross-file arity cycles converge without a client didSave. The cross-file e2e is a smoke test: with the didSave switched off it failed only in some runs, because the stale case is nondeterministic; the didSave effect is measured intests/test_e2e_cross_file.py.Known limits
JAVA_FUNCTIONAL_LSP_HOOK_WAITup to 4.Refs #109
🤖 Generated with Claude Code