davsclaus opened a new pull request, #29331:
URL: https://github.com/apache/camel/pull/29331

   _Claude Code on behalf of Claus Ibsen_
   
   [CAMEL-26689](https://issues.apache.org/jira/browse/CAMEL-26689). On top of 
#29322 (CAMEL-26679, the new faults, merged), so the model has them from the 
start.
   
   The rules of camel-chaos as data, for the tools that help to write them. The 
first one is the chaos screen (CAMEL-26608): a form, a list of known rules, and 
"chaos here" on a diagram node. An AI that turns a loose prompt into rules 
(stage 2, CAMEL-26607) and the docs can use it too.
   
   ### What is in the model
   `META-INF/org/apache/camel/chaos/chaos-model.json` in the camel-chaos jar, 
under a top-level `chaos` key:
   - **targets**: what each one matches, and what a tool picks it from 
(endpoints, components, routes, steps).
   - **hooks**: their targets, the faults each one offers, and whether it is 
reached only with `at=` (`reply`, `dlq`).
   - **faults**: `error`, `delay`, `drop`, `corrupt`, `lifecycle`, and `stall` 
(`shortFor: lifecycle action=suspend`). Each has its targets, hooks, options, 
and parameters with type, required, description, example and limits. For 
example `status` 300 to 599 with its HTTP schemes, `after` not at `reply`, the 
corrupt modes, the lifecycle actions, and `repeat` 1 to 100.
   - **options**: `at`, `rate` (`0.25`, `every:4`, `burst:5s/30s`), `until`, 
`from`, `expect`, `within`. Then the kinds and ops of an expectation, and the 
limits.
   - **recipes**: 17 known rules in plain words, grouped as Downstream, 
Messages, Consumers and routes, and Error handling. Each is a rule template 
with `${...}` placeholders, and each placeholder has its type, default, 
example, and where to pick its value from. Examples are "Returns an error (HTTP 
status)", "Did the work, then failed" (`at=reply`), "Is down for a while" 
(`rate=burst:`) and "The route flaps" (`repeat=`).
   
   ### How it stays true
   - The structure comes from the parser's own tables. `ChaosRuleParser` now 
has `faultKeys(fault, stall)`, `optionKeys(fault)` and `onlyWithAt(hook)`; the 
parser itself uses them, and so does `ChaosModel`. A parameter that the model 
has no description for fails the build.
   - `ChaosModelTest` is a golden test: the committed file must equal what 
`ChaosModel` produces. Regenerate it with `-Dcamel.chaos.updateModel=true`. The 
test also parses every recipe, once with its examples and once with its 
defaults, plus every corrupt mode, and checks the hooks against 
`ChaosRuleParser.offered()`.
   - The running integration still checks every rule a tool adds (`chaos-add` 
refuses with the reason). So a catalog of another version cannot add a broken 
rule; at worst it offers a recipe that the integration refuses with a clear 
message.
   
   ### Catalog
   - `PrepareCatalogMojo.executeChaosModel()` copies the file to 
`org/apache/camel/catalog/chaos-model.json`.
   - New `CamelCatalog.chaosModelJSon()` (`@since 4.24`).
   - The catalog copy is committed, since the `camel-package-maven-plugin` in 
`~/.m2` does not have this step yet.
   - Docs: a "The model of the rules" section in `chaos.adoc` (and its catalog 
copy), and the file plus the API in `camel-catalog.adoc`.
   
   ### Tests
   - camel-chaos: 650 tests pass (22 new in `ChaosModelTest`).
   - camel-catalog: all 142 tests of `CamelCatalogTest` pass, including the new 
`chaosModel`.
   - camel-package-maven-plugin compiles.
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)
   
   https://claude.ai/code/session_012nJsFsjqqFiwroeHRWaKbS
   


-- 
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]

Reply via email to