luigidemasi commented on code in PR #27082:
URL: https://github.com/apache/camel/pull/27082#discussion_r4142123943
##########
dsl/camel-jbang/camel-jbang-mcp/src/main/java/org/apache/camel/dsl/jbang/core/commands/mcp/TransformTools.java:
##########
@@ -151,6 +158,7 @@ private String transformYamlToXml(String yaml) throws
Exception {
RoutesDefinition rd = new RoutesDefinition();
rd.setRoutes(routeDefs);
+
rd.setSemantic(DefaultSemanticDefinitionConfigurer.getDefinition(ctx));
Review Comment:
The architecture changed in
[4e03971ee3ec](https://github.com/apache/camel/commit/4e03971ee3ecbcf65621a760d660dcdc656ba5bb)
to keep declarations entirely inside `camel-semantic`; the core SPI and model
exporter are removed. MCP now checks the public `SemanticQuestions` registry
and rejects conversions containing declarations, explaining that declarations
must be kept separately. This avoids silently dropping definitions without
adding a semantic SPI to core. Numeric placeholder errors remain covered.
_Generated by Codex via /oss-address-review on behalf of
[luigidemasi](https://github.com/luigidemasi)._
##########
components/camel-ai/camel-semantic/src/main/java/org/apache/camel/semantic/DefaultSemanticDefinitionConfigurer.java:
##########
@@ -0,0 +1,122 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.semantic;
+
+import java.util.LinkedHashMap;
+import java.util.Locale;
+import java.util.Map;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.model.PropertyDefinition;
+import org.apache.camel.model.app.SemanticDefinition;
+import org.apache.camel.model.app.SemanticQuestionDefinition;
+import org.apache.camel.model.spi.SemanticDefinitionConfigurer;
+import org.apache.camel.spi.Resource;
+import org.apache.camel.util.StringHelper;
+
+/** Converts Java/XML declarations to the same immutable questions used by
YAML and programmatic registration. */
+public class DefaultSemanticDefinitionConfigurer implements
SemanticDefinitionConfigurer {
+ @Override
+ public void configure(CamelContext context, Resource resource, String
source, SemanticDefinition definition) {
+ Map<String, SemanticQuestion> questions = new LinkedHashMap<>();
+ if (definition != null) {
+ for (SemanticQuestionDefinition question :
definition.getQuestions()) {
+ String name = question.getName();
+ if (name == null || name.isBlank()) {
+ throw new IllegalArgumentException("Semantic question
requires a nonblank name");
+ }
+ if (questions.containsKey(name)) {
+ throw new IllegalArgumentException("Duplicate semantic
question: " + name);
+ }
+ try {
+ questions.put(name, question(context, question));
+ } catch (IllegalArgumentException e) {
+ throw new IllegalArgumentException("Invalid semantic
question '" + name + "': " + e.getMessage(), e);
+ }
+ }
+ }
+ // A YAML loader can register its own declarations from the same
resource before its RouteBuilder runs.
+ SemanticQuestions.get(context).replace("model:" + source, resource,
questions);
+ }
+
+ /** Export a snapshot of the registered questions and their effective
decision policies. */
+ public static SemanticDefinition getDefinition(CamelContext context) {
Review Comment:
The model exporter is removed in
[4e03971ee3ec](https://github.com/apache/camel/commit/4e03971ee3ecbcf65621a760d660dcdc656ba5bb),
along with the semantic core model. Generic conversion now rejects inputs
containing declarations instead of serializing them; declarations must be kept
separately. Runtime defaults remain 0.5, 0 and `fail`.
_Generated by Codex via /oss-address-review on behalf of
[luigidemasi](https://github.com/luigidemasi)._
--
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]