Skip to content

CAMEL-25744: camel-jbang - the AI validator reports a comparison of CamelTimerCounter that can never be true, as the counter starts at 1 - #28040

Merged
davsclaus merged 3 commits into
mainfrom
fix/CAMEL-25744
Oct 18, 2026
Merged

davsclaus merged 3 commits into
mainfrom
fix/CAMEL-25744

Conversation

@davsclaus

@davsclaus davsclaus commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

CAMEL-25744: in the overnight benchmark of Oct 17-18 (ten runs of a local model on the example ladder), the hardest step asks for a timer that fires twice and picks a file on the first fire with CamelTimerCounter.

  • The mistake: in 8 of the 10 runs, the model compared the counter with 0. The counter counts the fires from 1 (TimerConsumer uses incrementAndGet()), so == 0 is never true, and both fires took the second file.
  • Why the model did not catch it: the option description says so since CAMEL-25530, but the model looked it up in only 2 of the runs. And camel_validate_source accepted the route.

What

  • HeaderChecks reports a comparison of CamelTimerCounter that can never be true (== 0, <= 0, < 1) or is always true (!= 0, > 0, >= 0, >= 1).
  • The message: "CamelTimerCounter counts the fires from 1 (the first fire is 1), so == 0 is never true: compare with 1 to pick the first fire".
  • It covers the Simple forms (${exchangeProperty.CamelTimerCounter} == 0, ${header.CamelTimerCounter == 0 ? ...}) and the Groovy one (exchange.getProperty('CamelTimerCounter', Integer) == 0).

Reading the counter as ${header.CamelTimerCounter} stays valid: a header lookup in Simple falls back to the exchange properties, and the validator already accepts it when includeMetadata is true.

Tests

  • SourceValidatorEndpointTest: the never-true comparisons (== 0, < 1) and the always-true ones (!= 0, > 0, >= 0, >= 1) are reported, and == 1, > 1 and >= 2 pass.
  • All camel-jbang-core tests pass (2531), CatalogDocExamplesTest included: no documentation example compares the counter with 0.

🤖 Generated with Claude Code

https://claude.ai/code/session_01STT6whBgK1AqsSsUKrnE8m

…amelTimerCounter that can never be true, as the counter starts at 1

In ten benchmark runs a local model compared the counter with 0 eight times
to pick the first fire. The counter counts the fires from 1, so == 0 is
never true and both fires took the second file. The validator now reports a
comparison of CamelTimerCounter that can never be true (== 0, <= 0, < 1) or
never be false (!= 0), in Simple and in Groovy, with a hint to compare with 1.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01STT6whBgK1AqsSsUKrnE8m
@davsclaus davsclaus added this to the 4.24.0 milestone Oct 18, 2026
@github-actions

Copy link
Copy Markdown
Contributor

🌟 Thank you for your contribution to the Apache Camel project! 🌟
🤖 CI automation will test this PR automatically.

🐫 Apache Camel Committers, please review the following items:

  • First-time contributors require MANUAL approval for the GitHub Actions to run
  • You can use the command /component-test (camel-)component-name1 (camel-)component-name2.. to request a test from the test bot although they are normally detected and executed by CI.
  • You can label PRs using skip-tests and test-dependents to fine-tune the checks executed by this PR.
  • Build and test logs are available in the summary page. Only Apache Camel committers have access to the summary.

⚠️ Be careful when sharing logs. Review their contents before sharing them publicly.

@github-actions github-actions Bot added the dsl label Oct 18, 2026

@gnodet-bot gnodet-bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The regex logic, operator precedence, and integration point are all correct. One gap: > and >= comparisons that are vacuously true (e.g. CamelTimerCounter > 0, >= 0, >= 1) are not detected — these are the symmetric counterparts of the covered cases.

This review was generated by an AI agent, Hermès on behalf of @gnodet.

@github-actions

github-actions Bot commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

🧪 CI tested the following changed modules:

  • dsl/camel-jbang/camel-jbang-core

🔬 Scalpel shadow comparison — Scalpel: 5 of 706 tested, 8 compile-only — current: 5 all tested

Maveniverse Scalpel detected 5 affected modules (current approach: 5).

Skip-tests mode would test 5 modules (1 direct + 5 downstream), skip tests for 8 (generated code, meta-modules)

Modules Scalpel would test (5)
  • camel-jbang-mcp ← downstream of org.apache.camel:camel-jbang-core
  • camel-jbang-plugin-mcp ← downstream of org.apache.camel:camel-jbang-core
  • camel-jbang-plugin-tui ← downstream of org.apache.camel:camel-jbang-core
  • camel-jbang-plugin-validate ← downstream of org.apache.camel:camel-jbang-core
  • camel-launcher-container ← downstream of org.apache.camel:camel-launcher
Modules with tests skipped (8)
  • camel-jbang-it
  • camel-jbang-main
  • camel-jbang-plugin-edit
  • camel-jbang-plugin-generate
  • camel-jbang-plugin-kubernetes
  • camel-jbang-plugin-test
  • camel-launcher
  • coverage

ℹ️ Shadow mode — Scalpel observes but does not affect test execution. Learn more

⚠️ Some tests are disabled on GitHub Actions (@DisabledIfSystemProperty(named = "ci.env.name")) and require manual verification:

  • dsl/camel-jbang/camel-jbang-core: 2 test(s) disabled on GitHub Actions

💡 Manual integration tests recommended:

You modified dsl/camel-jbang/camel-jbang-core. The related integration tests in dsl/camel-jbang/camel-jbang-it are excluded from CI. Consider running them manually:

mvn verify -f dsl/camel-jbang/camel-jbang-it -Djbang-it-test
All tested modules (14 modules, 2m 16s total)

Total reactor time: 2m 16s

Module Duration Status
Camel :: Launcher 40.4s SUCCESS
Camel :: JBang :: MCP 35.3s SUCCESS
Camel :: JBang :: Plugin :: Validate 26.8s SUCCESS
Camel :: JBang :: Plugin :: Testing 12.0s SUCCESS
Camel :: JBang :: Plugin :: Kubernetes 11.5s SUCCESS
Camel :: Coverage 3.6s SUCCESS
Camel :: JBang :: Plugin :: MCP 1.4s SUCCESS
Camel :: JBang :: Plugin :: Edit 1.2s SUCCESS
Camel :: JBang :: Plugin :: Generate 1.1s SUCCESS
Camel :: JBang :: Integration tests 0.9s SUCCESS
Camel :: Launcher :: Container 0.7s SUCCESS
Camel :: JBang :: Main 0.7s SUCCESS
Camel :: JBang :: Core n/a
Camel :: JBang :: Plugin :: TUI n/a

Top 20 slowest modules:

  • Camel :: Launcher (40.4s)
  • Camel :: JBang :: MCP (35.3s)
  • Camel :: JBang :: Plugin :: Validate (26.8s)
  • Camel :: JBang :: Plugin :: Testing (12.0s)
  • Camel :: JBang :: Plugin :: Kubernetes (11.5s)
  • Camel :: Coverage (3.6s)
  • Camel :: JBang :: Plugin :: MCP (1.4s)
  • Camel :: JBang :: Plugin :: Edit (1.2s)
  • Camel :: JBang :: Plugin :: Generate (1.1s)
  • Camel :: JBang :: Integration tests (0.9s)
  • Camel :: Launcher :: Container (0.7s)
  • Camel :: JBang :: Main (0.7s)

⚙️ View full build and test results

…erCounter, which are always true

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01STT6whBgK1AqsSsUKrnE8m

@gnodet-bot gnodet-bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-review: CAMEL-25744 — CamelTimerCounter comparison validation

The previous finding (missing > and >= operators in the regex) is fully resolved. The fix correctly detects all vacuously true/false CamelTimerCounter comparisons.

One minor observation:

The >= 0 case is handled correctly by the code (">=" .equals(op) && n <= 1 catches both >= 0 and >= 1) but is not exercised by any test. The existing tests cover:

  • Never-true: == 0, < 1 (and <= 0 implicitly)
  • Always-true: != 0, > 0, >= 1

Adding a test for >= 0 would complete the coverage, but this is a minor gap since the logic is already verified correct.

Overall the fix is solid — good work! ✅

This review was generated by an AI agent, Hermès on behalf of @gnodet.

…orted as always true

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Signed-off-by: Claus Ibsen <claus.ibsen@gmail.com>

@gnodet-bot gnodet-bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Previous finding is addressed. The >= 0 case is now covered by the test added in this commit — aTimerCounterComparisonThatIsAlwaysTrueIsReported explicitly asserts ">= 0 is always true". All operator variants are tested.

LGTM. ✅

This review was generated by an AI agent, Hermès on behalf of @gnodet.

@davsclaus davsclaus added the enhancement New feature or request label Oct 18, 2026
@davsclaus davsclaus self-assigned this Oct 18, 2026
@davsclaus
davsclaus merged commit b70ebb9 into main Oct 18, 2026
7 of 8 checks passed
@davsclaus
davsclaus deleted the fix/CAMEL-25744 branch October 18, 2026 18:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dsl enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants