luigidemasi opened a new pull request, #27564:
URL: https://github.com/apache/camel/pull/27564
# Description
Add `camel-wolf-defender`, a local prompt-injection expert for
`camel-semantic`. A named `injection` evaluation returns a Boolean verdict and
retains `P(INJECTION)` without replacing the message body. Routes can invoke it
through `${semantic('injection')}` or the semantic language.
The expert uses the operation contract introduced by CAMEL-25382. It
declares and validates its threshold, uncertainty band and uncertainty policy,
applies that policy once, and rejects unsupported operations and parameters
before inference. Batch input preflight checks character and token limits
before any expert performs inference.
Local CPU inference uses a pinned Wolf-Defender Small v2 FP32 ONNX artifact,
ONNX Runtime Java and DJL Hugging Face Tokenizers. Model files are explicitly
provisioned and checked by hash. Sessions and tokenizer resources are reused by
a bounded worker; timeout and interruption request cooperative cancellation,
and restart waits for a previously timed-out worker to terminate. Operational
failures remain errors and diagnostics omit submitted text.
The initial implementation rejects input above 2,048 tokens, including
special tokens, without truncation. It does not implement the model's
overlapping-window document protocol. Linux x86-64 CPU is validated; other
native platforms are documented as unverified.
Includes module/BOM registration, generated metadata and documentation,
synthetic native fixtures, a runnable example and opt-in real-model tests.
Excludes the shared semantic service descriptor from JBang's automatic
dependency mapping so discovery does not download an arbitrary provider. Static
operation inspection uses the shared class contract; expert-specific Catalog
APIs remain separate framework work.
Validation:
- Full root `mvnd -B -ntp -Dmaven.build.cache.enabled=false clean install
-DskipTests`: all 701 reactor modules passed.
- Wolf Defender: 34 unit tests, including real native tokenizer/tensor and
cancellation fixtures, plus two opt-in pinned-model integration tests. The
latter cover reference token IDs/probabilities and the documented YAML
configuration.
- Packaging plugin: 79 tests passed. Known dependency resolver: all six
tests passed.
- Wolf Defender source checks passed; generated documentation mirrors match
the source.
- Code review covered static contracts, batch preflight, lifecycle,
cancellation and discovery.
# Target
- [x] Targets `main` (Camel 4).
# Tracking
- [x] Tracked by
[CAMEL-25311](https://issues.apache.org/jira/browse/CAMEL-25311).
# Apache Camel coding standards and style
- [x] Commit has a meaningful subject and body.
- [x] Ran the full root build with tests skipped and included generated
changes.
# AI-assisted contributions
- [x] Prepared with Codex on behalf of @luigidemasi. The commit is signed
and includes Signed-off-by and AI co-authorship trailers.
Generated by Codex via /oss-fix-issue.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]