Repository navigation
Fix thread attribution (#222), paths with spaces (#233), Gradle 9.9 configuration (#228) - #248
Merged
Merged
Conversation
jafar-processor, parser-codegen and tools read
project(':parser-core').sourceSets.test.output inside dependencies {}.
There project(...) is a ProjectDependency, and Gradle 9.9 no longer
delegates project properties to it, so the build failed to configure:
"Could not get unknown property 'sourceSets' for project ':parser-core'
of type ...DefaultProjectDependency". Each file now resolves the same
expression once, outside the block, where project(...) is the Project.
Verified: on Gradle 9.9.1 (distribution checksum-verified) the unchanged
build fails with exactly that error at jafar-processor/build.gradle:35;
with the change, `help`, the three modules' compileTestJava and
:jfr-mcp:shadowJar succeed. The same tasks succeed on the pinned 9.4.1
wrapper.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Qr5KueVCgqpfF1u1vvFMmR
extractThreadId/extractThreadName read only eventThread. Execution and native-method samples carry their thread in sampledThread, so every sample landed in one bucket "unknown": jfr_tsa reported totalThreads=1, jfr_diagnose merged that, and jfr_use's active-thread count was 1. The thread is now read from sampledThread when the event has it, else from eventThread, as for jdk.JavaMonitorEnter, which the same helpers serve. Id and name come from the same field, so an event with both cannot get one thread's id and the other's name. R5: with the fix reverted, JfrAnalysesThreadAttributionTest fails 3 of 4 tests; the TSA test reports "threads ==> expected: <5> but was: <1>" on a recording it makes of four named workers plus the main thread. The checked-in TCK recording could not serve: its samples are datadog.ExecutionSample, which carries eventThread. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Qr5KueVCgqpfF1u1vvFMmR
) The one-shot commands (show, metadata, chunks, constants), the interactive shell's startup file and the TUI's turned the parsed Path back into "open <path>" and dispatched it. dispatch() splits a line at whitespace, so a path with a space opened only up to it. jafar-shell forwards these commands to the same code. CommandDispatcher.open(Path, String) opens from the Path and reports a failure as dispatch() does; the `open` command uses the same code after parsing its arguments. R5: with Main.java reverted, PathWithSpacesTest fails with exit 1 and "Error: /tmp/.../dir" / "No session open" for ".../dir with spaces/ sample input.jfr". Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Qr5KueVCgqpfF1u1vvFMmR
Contributor
Combined JUnit Test Report
HTML Test ReportsRun artifacts: https://github.com/btraceio/jafar/actions/runs/44954481280
|
) The #222 mistake - reading a sample's thread from eventThread, which jdk.ExecutionSample and jdk.NativeMethodSample do not have - was in two more places: - decorateByTime defaulted to eventThread/javaThreadId on both sides, so the documented "samples during monitor waits" query decorated no sample. Without threadPath/decoratorThreadPath the op now keeps null and each event's own thread is used. - Stack profiles read eventThread before sampledThread and the OS name before the Java name, so a sample's thread there could differ from jfr_tsa's, or be the other thread's name. EventThreads (shell-core, io.jafar.shell.jfrpath) is now the one rule: sampledThread when present, else eventThread; javaName, else osName; id and name from the same field. JfrAnalyses, Profiles and Decorators use it. The MCP query help, JFRPath.md and the tutorial now say so. Found on the way: a named parameter after fields= in decorateByTime or decorateByKey failed with "Expected ')'" - parseFieldList read "threadPath" as one more field - which broke the tutorial's explicit thread-path example. The field list now stops before `name=`. R5: with the production changes reverted, decorateByTimeMatchesASamplesSampledThreadByDefault fails ("row onThread1 ==> expected: <MyLock> but was: <null>"), aSampleIsCountedUnderItsSampledThreadsJavaName fails ("expected: <[worker-0]> but was: <[os-7]>") and namedParametersMayFollowTheFieldList fails ("Expected ')' [at 96]"). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Qr5KueVCgqpfF1u1vvFMmR
The previous commit fixed callers holding a Path. The open command
itself still could not open such a path: jfr-shell's dispatcher splits
every line at whitespace and open read only the first word, and the
transcript `ask` writes ("open <path>", unquoted) failed when replayed.
jafar-shell kept the rest of the line, quotes included.
OpenArguments (shell-core) reads open's argument for both shells: the
path is everything up to --alias, or the text in a leading pair of
quotes; quote() writes a path back in a form parse() reads. jfr-shell's
open gets its line unsplit; jafar-shell's uses the same parser and
refuses --alias instead of reading it as part of the path; the
transcript quotes a path when it needs it. JdkMetadataEndToEndTest
opens through dispatcher.open and quotes the path it types.
R5: with the two shells' changes reverted,
PathWithSpacesTest#theOpenCommandTakesAPathWithSpaces fails (`Error:
"/tmp/.../dir`) and both OpenPathWithSpacesTest tests fail ("file not
found: \"/tmp/.../a b.jfr\"" and "file not found: .../plain.jfr --alias
x").
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Qr5KueVCgqpfF1u1vvFMmR
The previous commit added one sentence to the jafar://help/jfrpath
resource ("Without threadPath/decoratorThreadPath, each event's own
thread is matched: sampledThread for samples, else eventThread."), and
ToolCatalogSnapshotTest pins that resource. The snapshot differs by
exactly that sentence; no tool name, parameter or response shape
changed, so no jafar-perf skill in btraceio/agent-plugins needs an
update (doc/agents/Mcp.md).
Regenerated with ./gradlew :jfr-mcp:test --tests ToolCatalogSnapshotTest
-Dmcp.updateSnapshot=true; :jfr-mcp:test then passes, 415 tests.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Qr5KueVCgqpfF1u1vvFMmR
jbachorik
marked this pull request as ready for review
November 21, 2026 21:43
…read paths
From a review of the previous commits:
- OpenArguments.quote() could write a line parse() did not read back:
a path with whitespace and both quote characters was put in single
quotes, and parse() stopped at the path's own apostrophe. quote() now
tries the double-quoted, single-quoted and bare forms and returns the
first that reads back as exactly the path, else throws; the ask
transcript then writes a comment saying the path must be opened by
hand instead of a broken open line.
- A leading quote without a complete quoted form (`'odd.jfr`) was an
"unclosed quote" error; it is again part of the file name.
- jfr-shell's open used to ignore words after the path ("open rec.jfr
# main"). When the whole unquoted text names no file but its first
word does, open keeps doing that and prints a note.
- Parse errors in jfr-shell's open went through dispatch's catch and
read "Error: Usage: ..."; they are reported as usage messages.
- The decorateByTime completer still named the old defaults.
- DecorateByTimeOp's public thread-path fields could be null; they are
empty when not given, which means "each event's own thread".
CHANGELOG records the open behaviour changes and the field's new value.
R5: with each fix mutated back, its test fails -
quoteIsReadBackAsTheSamePath/TranscriptOpenLineTest ("unclosed ' in
'/tmp/Bob's \"prod\" run.jfr'"), quoteRefusesAPathNoFormReadsBack
(nothing thrown), aLeadingQuoteWithoutAQuotedFormIsPartOfThePath
("unclosed ' in 'odd.jfr"), trailingWordsAfterAnExistingFileStillOpenIt-
WithANote (script fails on "plain.jfr # main recording"),
aMalformedOpenLineIsAUsageMessage ("Error: Usage: ..."),
omittedThreadPathsAreEmptyNotNull ("expected: <[]> but was: <null>").
The completer text has no test.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Qr5KueVCgqpfF1u1vvFMmR
This was referenced Nov 22, 2026
jfr_tsa reports every sample as thread 'unknown' (jdk.ExecutionSample has no eventThread field)
#222
Closed
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.
Summary
Three issue fixes (#222, #233, #228), one commit each, plus two commits that finish #222 and #233 after a code review found the same mistakes elsewhere, one that accepts the resulting MCP contract snapshot, and one with the fixes from a second review.
jfr_tsaput every sample under thread "unknown".JfrAnalyses.extractThreadId/extractThreadNameread onlyeventThread;jdk.ExecutionSampleandjdk.NativeMethodSamplecarrysampledThread(JDK 25 metadata:Thread sampledThread;, noeventThread). The thread now comes fromsampledThreadwhen the event has it, elseeventThread, which the other events these helpers read use (verified forjdk.JavaMonitorEnterfrom JDK metadata and fordatadog.ExecutionSamplefrom Jafar's field list;datadog.QueueTimenot checked). Id and name are read from the same field. Also affectsjfr_diagnose(merges TSA) andjfr_use's active-thread count (same helper,analyzeThreadsResource)."open " + pathand dispatched it;dispatch()splits on whitespace. NewCommandDispatcher.open(Path, String)opens from thePathand reports a failure exactly asdispatch()does (io.error("Error: " + message)); theopencommand calls the same code after parsing.jafar-shell show …forwards toio.jafar.shell.Main, so it is covered by the same change.jafar-processor,parser-codegenandtoolsreadproject(':parser-core').sourceSets.test.outputinsidedependencies {}, whereproject(...)is aProjectDependency. Each now resolves it once outside the block. Same expression, same classpath.eventThread-only assumption sat indecorateByTime's default thread paths (so the documentedevents/jdk.ExecutionSample | decorateByTime(jdk.JavaMonitorWait, ...)decorated nothing) and in stack profiles (eventThreadand OS name first, so a sample's thread could differ fromjfr_tsa's). NewEventThreads(shell-core,io.jafar.shell.jfrpath) is the one rule —sampledThreadif present elseeventThread, Java name else OS name, id and name from one field — used byJfrAnalyses,ProfilesandDecorators. MCP query help,JFRPath.mdand the tutorial updated; the MCP contract snapshot is re-accepted for the one changed help sentence. Found on the way: a named parameter afterfields=indecorateByTime/decorateByKeyfailed withExpected ')'(the tutorial's explicit-path example); the field list now stops beforename=.open(jafar-shell show splits paths containing spaces after argument parsing #233): theopencommand itself still read only the path's first word injfr-shell(so theasktranscript, which writesopen <path>, failed on replay), andjafar-shellkept quotes. NewOpenArguments(shell-core) readsopen's argument for both shells — everything up to--alias, or a leading quoted string — andquote()writes one back; the transcript uses it.jafar-shell'sopenrefuses--aliasrather than reading it as part of the path.JdkMetadataEndToEndTestopens throughdispatcher.openand quotes the path it types.OpenArguments.quote()could write a lineparse()did not read back (whitespace plus both quote characters); it now returns the first of double-quoted, single-quoted and bare that reads back exactly, else throws, and the transcript then writes a comment instead of a brokenopen. A leading quote without a complete quoted form is part of the file name again (open 'odd.jfr).jfr-shell'sopenkeeps its old habit of ignoring words after an existing file (open rec.jfr # main) when the whole text names no file, with a printed note. Parse errors are usage messages, notError: Usage: …. ThedecorateByTimecompleter names the new defaults.DecorateByTimeOp's thread-path fields are empty, nevernull, when not given.doc/agents/DataShapes.md: new case "An event's thread is not alwayseventThread" (the jfr_tsa reports every sample as thread 'unknown' (jdk.ExecutionSample has no eventThread field) #222 lesson: a"unknown"default hid the miss, and the test recording was a Datadog one whose samples do haveeventThread).Fixedentries (the three issues,decorateByTime's default, stack-profile thread names, thefields=parse error; the jafar-shell show splits paths containing spaces after argument parsing #233 entry also coversopenand its behaviour changes).Deliberately not in this PR: no escaping inside quotes in
open(the rare path no form reads back — whitespace, both quote characters and a leading/trailing space or--aliasword — is refused byquote()); theOpened session #1: …line before the JSON in one-shot output (#234) is unchanged; the one-shot behaviour after a failed open (the command still runs, as before) is unchanged.Parity: not applicable — no untyped-parser code (parser-core
impl/internal_api, go-parser) is touched.Typed-Parity: not applicable — no typed-generator production code is touched; only the test classpath declaration in
jafar-processor/build.gradleandparser-codegen/build.gradlemoves.Validation
#228 (Gradle 9.9.1 distribution, sha256 checked against
services.gradle.org):gradle help→Build file '…/jafar-processor/build.gradle' line: 35 … Could not get unknown property 'sourceSets' for project ':parser-core' of type …DefaultProjectDependency.gradle help :jafar-processor:compileTestJava :parser-codegen:compileTestJava :tools:compileTestJava :jfr-mcp:shadowJar→BUILD SUCCESSFUL, 46 tasks executed.#222
JfrAnalysesThreadAttributionTestfails 3 of 4 (threads ==> expected: <5> but was: <1>;expected: <42> but was: <unknown>;expected: <42> but was: <7>); all 4 pass with it. The TSA test records its ownjdk.ExecutionSamplefrom four named workers plus the main thread and compares TSA's per-thread counts withgroupBy(sampledThread/javaThreadId).Repro.javarecorded on JDK 25 (1,062jdk.ExecutionSample), thenjfr_open+jfr_tsaover the builtjfr-mcpjar's stdio transport:totalThreads: 5— main 295, worker-0 217, worker-1 207, worker-2 176, worker-3 165, identical tojfr_query "events/jdk.ExecutionSample | groupBy(sampledThread/javaName)"(which also lists two 1-sample threads that TSA'sminSamples=5drops).#233
Main.javareverted,PathWithSpacesTestfails: exit 1,Error: /tmp/…/dir/No session openfor…/dir with spaces/sample input.jfr; passes with the fix.user.home, jafar backend via-Djfr.shell.backend.jars(nothing installed):jfr-shell-…-all.jarandjafar-shell-…-all.jarshow '<dir with spaces>/sample input.jfr' 'events/jdk.ExecutionSample | count()' --format json→"count": 8000, exit 0, same as the plain path. Interactivejfr-shell '<dir with spaces>/sample input.jfr'withshow …on stdin →Opened session #1: dir with spaces/sample input.jfr, count 8000.Review follow-up
decorateByTimeMatchesASamplesSampledThreadByDefault(row onThread1 ==> expected: <MyLock> but was: <null>),aSampleIsCountedUnderItsSampledThreadsJavaName(expected: <[worker-0]> but was: <[os-7]>, the other thread's OS name),namedParametersMayFollowTheFieldList(Expected ')' [at 96]),PathWithSpacesTest#theOpenCommandTakesAPathWithSpaces(Error: "/tmp/…/dir), bothOpenPathWithSpacesTesttests (file not found: "/tmp/…/a b.jfr",file not found: …/plain.jfr --alias x). All pass with the changes, as do all ofio.jafar.shell.jfrpath.*.open "<dir with spaces>/work run.jfr"(as the transcript writes it) givescount 577, exit 0, in bothjfr-shellandjafar-shell.decorateByTime(app.Work, fields=label)with default thread paths, on a real recording where two workers commit anapp.Workduration event around their busy loops:worker-0→job-0on 192 samples,worker-1→job-1on 191,main(never insideapp.Work) undecorated on its 192.Second review
quoteIsReadBackAsTheSamePath/TranscriptOpenLineTest(unclosed ' in '/tmp/Bob's "prod" run.jfr'),quoteRefusesAPathNoFormReadsBack(nothing thrown),aLeadingQuoteWithoutAQuotedFormIsPartOfThePath(unclosed ' in 'odd.jfr),trailingWordsAfterAnExistingFileStillOpenItWithANote(script fails onplain.jfr # main recording),aMalformedOpenLineIsAUsageMessage(Error: Usage: …),omittedThreadPathsAreEmptyNotNull(expected: <[]> but was: <null>). The completer text has no test.58e59e7(env -u _JAVA_OPTIONS ./gradlew --no-daemon spotlessCheck :arch-tests:test pmdMain :shell-core:test :jfr-shell:test :jfr-shell:jdkMetadataTest :jafar-shell:test :jfr-mcp:test, fresh reports only): spotless, ArchUnit 22,pmdMainpass; shell-core 599, jfr-shell 988,jdkMetadataTest7, jafar-shell 70, jfr-mcp 415 — no failures.Suites and gates (
./gradlew spotlessCheck :arch-tests:test pmdMain :shell-core:test :jfr-shell:test :jafar-shell:test :jfr-mcp:test :jafar-processor:test :parser-codegen:test :tools:test --continue, wrapper 9.4.1, only reports written by this run counted): spotless, ArchUnit (22) andpmdMainfor every module pass. Tests: shell-core 585, jfr-shell 983, jafar-shell 68, jfr-mcp 415, jafar-processor 44, parser-codegen 246, tools 36 — one failure by name,ShellArtifactTest#commandLineScriptRunsInThisShellAcrossFormats. It asserts the child JVM's stderr holds only progress lines, and this sandbox sets_JAVA_OPTIONS, so every JVM printsPicked up _JAVA_OPTIONS: …there (the first line of the failure message). Withenv -u _JAVA_OPTIONS,ShellArtifactTestpasses 40/40. I did not run the same suites onmainfor an R6 comparison; the only failing name is explained above. Those numbers are for the first three commits.After the review follow-up (
env -u _JAVA_OPTIONS ./gradlew --no-daemon spotlessCheck :arch-tests:test pmdMain :shell-core:test :jfr-shell:test :jfr-shell:jdkMetadataTest :jafar-shell:test :jfr-mcp:test --continue, fresh reports only): spotless, ArchUnit (22) andpmdMainpass; shell-core 596, jfr-shell 984, jfr-shelljdkMetadataTest7 (incl. the editedJdkMetadataEndToEndTest), jafar-shell 70 (incl.ShellArtifactTest, with the sandbox's_JAVA_OPTIONSunset), all passing. jfr-mcp failed 2, bothToolCatalogSnapshotTest: the MCP contract snapshot pins thejafar://help/jfrpathtext, and the follow-up added one sentence to it. The regenerated snapshot differs by exactly that sentence (accepted in73b8563, no tool name/parameter/response change, so nojafar-perfskill is affected);:jfr-mcp:testthen passes, 415 tests.jafar-processor,parser-codegenandtoolswere not re-run for the follow-ups; they do not touch them.Not verified
TuiShell.openIfPresent): changed the same way asShell.openIfPresent, not driven (needs a terminal).jfr_use/jfr_diagnoseoutput after the jfr_tsa reports every sample as thread 'unknown' (jdk.ExecutionSample has no eventThread field) #222 change: same helper, not called through MCP.asktranscript writer itself: not driven (it runs after an LLM answer);TranscriptOpenLineTestcovers the line it writes (CommandDispatcher.transcriptOpenLine), andPathWithSpacesTestthat line opening through a script.decorateByTimecompleter text: changed, no test.🤖 Generated with Claude Code
https://claude.ai/code/session_01Qr5KueVCgqpfF1u1vvFMmR