Skip to content

fix: resolve the 3.0.0-RC1 pre-release findings - #1027

Merged
jbachorik merged 16 commits into
developfrom
claude/amazing-fermat-9u5o7j
Nov 17, 2026
Merged

jbachorik merged 16 commits into
developfrom
claude/amazing-fermat-9u5o7j

Conversation

@jbachorik

@jbachorik jbachorik commented Nov 17, 2026 •

Copy link
Copy Markdown
Collaborator

What does this change do?

Fixes found in the 3.0.0-RC1 pre-release check: two release-pipeline blockers, a verifier bypass, several agent/CLI behaviours that failed silently or did nothing, and documentation that did not match the code.

Release pipeline

  • io.btrace:btrace is published with -sources.jar and -javadoc.jar; Maven Central rejects a release without them (snapshots are not checked, so RC1 would have been the first failure). verifyBtracePublication guards the Sonatype upload.
  • Both Gradle plugins declare tags; publishPlugins --validate-only failed without them.
  • The btrace-latest JBang alias follows the develop snapshot after a release (with the //REPOS line snapshots need) instead of being moved to the release.
  • Curated release notes for v3.0.0-RC1.

Security

  • The agent's verifier for packs (btracec output, or any bytes a client submits) never detected loops (its label map was never filled) and ignored @BTrace(trusted = true). A trusted probe precompiled with btracec ran without -u. Both are enforced now (PersistedProbeVerifier).

Behaviour

  • Startup probes (script=) that inject a bundled extension work: extensions initialize before startup scripts.
  • Every failed probe load reports why: to the client (a probe rejected in verification used to exit 255 with no message) or in the target's log (startup probes, missing or .java script= files).
  • scriptOutputDir= takes effect (it was parsed but never read).
  • A handler calling another handler is a verification error on both layers; it used to compile and silently do nothing. Making it work is tracked in Let a handler call another handler (split guarded entry from handler body) #1028.
  • btracer -u passes trusted=true (it passed unsafe=true, which the agent does not know); btracex list works without an exported BTRACE_HOME; btracec -trusted says it has no effect.
  • Extension scripts compile without BTRACE_HOME; an explicit -Dbtrace.libs wins.
  • Numeric oneliner filters (if args[0]>100) compile.
  • Three bundled samples that did not compile are fixed.
  • The JMH quick job's -Pjmh.* settings are read.

Documentation
About 60 files corrected against the code and real runs (scripts compiled with btracec, oneliners and flows run against live JVMs): README, Getting Started, Quick Reference, Tutorial, Oneliner Guide, FAQ, Troubleshooting, the migration guide, all 12 tutorials, the extension and architecture docs, docker, release docs, SECURITY.

Related issue

N/A (3.0.0-RC1 pre-release check). Follow-up: #1028.

Scope and compatibility

  • I identified the affected module(s) and kept unrelated changes out of this PR.
  • This preserves the supported Java/runtime compatibility tiers, or the change is documented below.
  • This does not change the masked-JAR layout, class-loader boundary, or wire protocol.
  • If it does, I updated the relevant architecture documentation and verification plan.

Compatibility or migration notes:

  • A probe that requests trusted mode now needs -u (or trusted=true) whether it is submitted as source, class or pack. A precompiled trusted pack that used to run without -u is refused, with the remedy in the message.
  • A handler that calls another guarded handler no longer compiles; the call never ran.
  • scriptOutputDir= now takes effect; without it the output location is unchanged.

Instrumentation backends

No change to either backend's instrumentation (Instrumentor and helpers; btrace-agent/src/main/java24/); the verifier and agent changes sit before instrumentation. Golden data is unchanged; it was not regenerated.

Testing

  • Unit tests
  • Integration tests (if applicable)
  • spotlessCheck
  • Documentation/link or sample verification (if applicable)

Commands and results:

GRADLE_USER_HOME=$(pwd)/.gradle-user ./gradlew build
  -> BUILD SUCCESSFUL; 2074+ unit tests, 0 failures (JDK 28 ClassFile-backend suite included)
TEST_JAVA_HOME=<jdk> GRADLE_USER_HOME=$(pwd)/.gradle-user ./gradlew -Pintegration :integration-tests:test
  -> 0 failures. At 7d06fe21: JDK 8 (126 passed), 17 (131), 21 (131), 28-ea (132);
     at 1ee5495e: JDK 11 (130), 25 (130). CI on 38fd273d: all lanes (8, 11, 17, 21, 25, 27, 28-ea) green
version=3.0.0-RC1: ./gradlew clean :btrace-dist:build :btrace-dist:fatAgentJar :btrace-dist:explodeExtensions
  ./gradlew :btrace-dist:verifyBtracePublication verifyReleaseExtensionPublications
  -> [dist] Verified the Maven publication of io.btrace:btrace:3.0.0-RC1 (jar, sources, javadoc, pom)
  -> [release] Verified Maven publications of 8 release extensions
scripts/verify-release-artifacts.sh ... --version 3.0.0-RC1   -> release artifact verification PASSED
scripts/release-smoke.sh ... --version 3.0.0-RC1              -> release smoke PASSED
./gradlew -p btrace-gradle-plugin -PbtraceVersion=3.0.0 publishPlugins --validate-only
  -> passes local validation (server step needs real Plugin Portal keys)
python3 scripts/guardrails/check_*.py                          -> all OK

Every new test was run against the unfixed code first and fails there: PersistedProbeVerifierTest, HandlerCallVerifierTest, BTraceDslVerifierTest (handler calls), OnelinerIntegrationTest.testCompileNumericArgFilter, AgentStartupScriptIntegrationTest, TrustedProbeRefusalIntegrationTest, LauncherExtensionCompileIntegrationTest, verifyBtracePublication.

Documentation and release impact

  • User-facing documentation is updated, or no documentation change is needed.
  • Release notes/changelog are updated, or no release-note entry is needed.
  • Samples, distribution contents, or published coordinates are updated if affected.
  • This change is safe to merge independently of a release, or the dependency is explained below.

Release notes / follow-up work:

Final checklist

  • I reviewed the complete diff and removed unrelated changes.
  • New or changed behavior has appropriate tests, or the reason for not adding them is explained above.
  • User-facing behavior, APIs, samples, and documentation are consistent with this change.
  • I did not include generated build output, local configuration, credentials, or other accidental files.

🤖 Generated with Claude Code

https://claude.ai/code/session_01Qr5KuiEbTbQMuGQTUU4FhF


This change is Reviewable

Maven Central rejects a release component without -sources.jar and
-javadoc.jar; the btrace publication carried only the jar and the POM, so
the first non-snapshot upload (3.0.0-RC1) would fail Central validation.
Attach both, and add verifyBtracePublication, which publishes to a scratch
repository and fails when either is missing. It runs with check and before
the Sonatype upload.

publishPlugins --validate-only failed with "Plugin 'btraceExtension' has
no 'tags' property set"; set tags on both plugins.

Add curated notes for 3.0.0-RC1, state in the 3.0.0 notes that the bundled
extensions are published to Central, and fix the JBang command in the
release summary.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Qr5KuiEbTbQMuGQTUU4FhF
Docker and Kubernetes examples used script names the client rejects
(*.btrace, files not named after their class) and a btracer invocation
without a compiled script; the v2 protocol document described interfaces,
adapter classes, a field order and size ratios that do not match
btrace-core; releasing.md named release/X.Y branches the script refuses
and said only btrace-dist is published to Maven Central.

Also documents the per-candidate release notes file and the publication
check that guards the Sonatype upload.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Qr5KuiEbTbQMuGQTUU4FhF
…ported

bin/btrace and bin/btracec resolve BTRACE_HOME for themselves but do not
export it, and the compiler's fallback looked only for the pre-3.0
btrace-compiler/btrace-boot jars on its classpath. A script that injects a
bundled extension therefore failed to compile with "package
io.btrace.metrics does not exist" unless the user exported BTRACE_HOME,
which tutorials 04, 07, 10 and 11 do not ask for.

Recognize <home>/libs/btrace.jar as well. CompilerHelperBTraceHomeTest
covers the classpath parsing; LauncherExtensionCompileIntegrationTest runs
the distribution's bin/btracec with BTRACE_HOME removed. Both fail with the
btrace.jar match reverted.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Qr5KuiEbTbQMuGQTUU4FhF
…he code

Troubleshooting quoted error messages that the code does not produce
("verification failed", "No methods matched for probe", "method not
instrumented", ClassNotFoundException for a missing script=), offered
snippets that do not compile in the flat DSL (timeMillis, threadName(),
jstack(5), Statsd.send), and said -u alone lifts loop and file-I/O checks
(the script also needs @btrace(trusted = true)). Tutorials 01 and 10 quoted
"Can not attach to PID" (the client prints "Failed to attach to PID").
The migration guide said 2.x sources need nothing; their org.openjdk.btrace
imports fail to compile. Demo 07's after-detach sample contradicted its
claim that throughput returns to baseline; it is now a measured run.

Each change was checked by compiling the snippet with btracec or running
the command against the built distribution.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Qr5KuiEbTbQMuGQTUU4FhF
… guardrail

5b941fe reads each published module's source sets through project(path),
which check_layering.py cannot parse and reports as a problem, failing the
guardrails job. Name the variable publishedSourcePath and list it under
dynamic_project_references with its reason (task wiring, not a dependency).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Qr5KuiEbTbQMuGQTUU4FhF
- An explicit -Dbtrace.libs now names the engine whose extensions a script
  compiles against. 6de603f derived the home from libs/btrace.jar on the
  classpath first, so a client pointed at a lean engine still compiled
  against the full distribution next to it; EmbeddedExtensionIntegrationTest
  .leanEngineCannotLinkTheSameProbe failed on JDK 8, 11, 17, 21, 25 and 28.
- 'if args[0]>100' generated ((Number) args[0]).longValue(), a method call
  the verifier refuses, so the documented filter never compiled. It now
  compares BTraceUtils.parseDouble(BTraceUtils.str(args[i])).
  OnelinerIntegrationTest.testCompileNumericArgFilter fails on the old
  generator.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Qr5KuiEbTbQMuGQTUU4FhF
- btracer -u passed unsafe=true, which is not an agent argument, so the
  launcher's trusted mode did nothing. It now passes trusted=true; a
  @btrace(trusted = true) probe launched with btracer -u runs.
- bin/btracex resolved BTRACE_HOME but did not export it, and btracex
  reads the variable, so 'btracex list' printed nothing unless the user had
  exported it. Covered by btracexListsBundledExtensionsWithoutBtraceHome
  (the old launcher lists 0 extensions, the new one 8).
- The btracex usage lists the zip and URL forms install already accepts.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Qr5KuiEbTbQMuGQTUU4FhF
v2-protocol-tests.yml passes -Pjmh.warmupIterations/-Pjmh.iterations/
-Pjmh.fork, but btrace-core/build.gradle hard-coded 3/5/2, so the quick job
ran at full length. The build now reads the properties (defaults
unchanged); a run with 0/1/1 reported 'Warmup: <none>', '1 iterations'
and 'Fork: 1 of 1'. The workflow uploaded build/reports/jmh and
build/jmh-results; the plugin writes build/results/jmh/results.txt.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Qr5KuiEbTbQMuGQTUU4FhF
…led load

- Startup probes (script=) ran before the extension system was initialized,
  so a probe with a required @injected extension was refused even when the
  extension was allowed ("ExtensionIndy.bridge not initialized"). The
  extension system now initializes first.
- A startup probe that failed to load was dropped without a reason: the
  ErrorCommand had no runtime to go to. Its reason is now logged, e.g.
  "Blocked privileged extension. Required=[THREADS, REFLECTION,
  CLASSLOADER]" with the remedy.
- A probe named in script= that is missing or is a .java source was
  skipped with no message at any level. The agent now warns
  (StartupScriptReport; Main.java does not grow).
- A probe the agent rejected in verification closed the connection with no
  message to the client (exit 255). The verifier's report now reaches it,
  e.g. "Trusted mode, requested by the script (@btrace(trusted = true)),
  not allowed: deploy it with btrace -u".
- scriptOutputDir= was parsed but never read. It now sets the output
  directory; without it the default is unchanged (the scriptdir= directory,
  else the working directory).
- btracec -trusted has never had an effect: it now says so, and its usage
  line no longer claims it disables checks. The agent usage no longer says
  script= must be the last argument.

AgentStartupScriptIntegrationTest covers the first four on a real target;
each of its tests fails with its fix reverted.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Qr5KuiEbTbQMuGQTUU4FhF
…packs

A pack (btracec's default output, or any bytes a client submits) is checked
by the agent's own bytecode verifier unless the agent runs trusted. That
verifier had two holes:

- Its loop check looked up jump targets in a label map that nothing filled,
  so a backward jump never failed verification.
- It ignored @btrace(trusted = true), which the class verifier refuses
  without trusted mode.

So a trusted probe compiled with btracec ran on an agent without -u, while
the same probe sent as source or as a plain class was refused. Both checks
now apply. The verifier moves to PersistedProbeVerifier, which keeps
BTraceProbePersisted under the size ratchet and makes it unit-testable;
PersistedProbeVerifierTest's loop and trusted cases fail with the fix
reverted. TrustedProbeRefusalIntegrationTest deploys the btracec pack
through the real client.

Eleven instrumentation tests loaded @btrace(trusted = true) traces with
trusted mode off and passed only because of the second hole; they now load
those traces trusted, and their golden data is unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Qr5KuiEbTbQMuGQTUU4FhF
Two statements on the gh-pages landing page are wrong today (the agent
plugin's MCP server does resolve the snapshot; CI replays the demos'
probes, not run.sh). This session cannot push gh-pages, so the source patch
and the apply-and-rebuild steps are kept here.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Qr5KuiEbTbQMuGQTUU4FhF
Each change was checked against source or a real run on the built
distribution (scripts compiled with btracec, oneliners and flows run
against live JVMs on JDK 21). Highlights:

- Oneliners match only the named class: examples on java.sql.Statement and
  javax.sql.DataSource (interfaces, so nothing is traced) use a class regex
  or a concrete class, and package wildcards that need subpackages use **.
- Trusted mode needs @btrace(trusted = true) and -u together; -u alone lifts
  no check, and oneliners are always untrusted.
- Every bundled extension is published to Maven Central as
  io.btrace:<id>:<version>; the fat-agent plugin embeds one with
  maven('io.btrace:<id>:<version>:extension@zip').
- scriptOutputDir= defaults to the scriptdir= directory, else the working
  directory; btracex and the compiler find the installation without an
  exported BTRACE_HOME, so no step asks for it.
- Snippets that did not compile in the flat DSL (Statsd.send, threadName(),
  jstack(5), printf in verified scripts, Property as script argument) and
  timer handlers that threw before their first sample are fixed.
- SECURITY.md: -javaagent (not -agentpath), loopback-only binding with no
  bindAddress property, btrace.comm.allowV1 defaults to true, and the
  references to files that do not exist are gone.
- JDKCompatibility: toolchains are not downloaded; JDK 8, 11, 24 and 28
  must be installed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Qr5KuiEbTbQMuGQTUU4FhF
Every guarded handler (@OnMethod, @ontimer, @onevent, @onerror, @OnProbe,
@PeriodicEvent) starts with 'if (!enter()) return;', and enter() refuses on
a thread already running probe code. A guarded handler calling another one
therefore compiled and then did nothing: the callee returned at once.

Both verifier layers now refuse the call (no.handler.calls) and name the
remedy, a plain static helper shared by both handlers:
- the source verifier (VerifierVisitor),
- the agent, for classes and packs (HandlerCallVerifier), so a hand-made
  or precompiled pack cannot bring the call back.
@onexit and @OnLowMemory handlers are not guarded and may still call
guarded ones. The pack verifier runs the check last, so a handler that
recurses is still reported as an endless loop.

BTraceDslVerifierTest and HandlerCallVerifierTest fail with the checks
removed. All 59 bundled samples compile the same before and after. Making
the call work instead is tracked in #1028.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Qr5KuiEbTbQMuGQTUU4FhF
…uild

AWTEventTracer, SubtypeTracer and ThreadCounterBean passed an AWTEvent, a
char and a long to the flat-DSL print/println, which take a String, so
btracec rejected them. They now pass str(...) or a String.
everyBundledSampleCompiles compiles every sample in the distribution with
its own bin/btracec and fails on the old samples.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Qr5KuiEbTbQMuGQTUU4FhF
update-jbang-catalog rewrote the //DEPS line of both catalog scripts to
the release version, so after a release the snapshot alias btrace-latest
pointed at the release. A major or minor release now moves it to the next
develop snapshot (next_snapshot); a patch release, whose next_snapshot is
the release branch's, leaves it alone. The step also adds the //REPOS line
that lists Maven Central and the Central snapshot repository, without
which a snapshot does not resolve: any //REPOS replaces JBang's default
Central lookup.

Checked by running the extracted step against copies of the catalog for a
minor and a patch release, twice (the //REPOS line is added once).

The catalog itself cannot be pushed from here; internal/launch/3.0.0/
holds the two-line patch that makes btrace@btraceio resolve today, with
the evidence.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Qr5KuiEbTbQMuGQTUU4FhF
@jbachorik jbachorik changed the title fix(release): make io.btrace:btrace and the Gradle plugins publishable fix: resolve the 3.0.0-RC1 pre-release findings Nov 17, 2026
…lied

btraceio/jbang-catalog now declares the //REPOS line in btrace.java and
btrace-latest.java (f058067, merged in 3dd8be7).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Qr5KuiEbTbQMuGQTUU4FhF
@jbachorik
jbachorik merged commit dc510c1 into develop Nov 17, 2026
21 checks passed
@jbachorik
jbachorik deleted the claude/amazing-fermat-9u5o7j branch November 17, 2026 08:53
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