This is an automated email from the ASF dual-hosted git repository.

luigidemasi pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-kit.git

commit 8809512d8c4c7a38b1e1a809345e6be46b650e52
Author: Jinal Sarvaiya <[email protected]>
AuthorDate: Thu Nov 26 14:28:03 2026 +0000

    fix: address critical DataMapper and Ship prompt issue
---
 .../guides/greenfield-interview.md                 |  33 ++++--
 .../camel-design/guides/datamapper-interview.md    |  46 ++++++--
 .../brainstorm/InterfaceContractDiscoveryTest.java | 118 ++++++++++++++++++++-
 3 files changed, 177 insertions(+), 20 deletions(-)

diff --git 
a/kit/camel-kit-core/src/main/resources/skills/camel-brainstorm/guides/greenfield-interview.md
 
b/kit/camel-kit-core/src/main/resources/skills/camel-brainstorm/guides/greenfield-interview.md
index 066ac7c4..48528bef 100644
--- 
a/kit/camel-kit-core/src/main/resources/skills/camel-brainstorm/guides/greenfield-interview.md
+++ 
b/kit/camel-kit-core/src/main/resources/skills/camel-brainstorm/guides/greenfield-interview.md
@@ -211,8 +211,14 @@ I'll propose a [contract-type] definition based on your 
requirements.
 
 This will be included in the design specification for your approval before 
implementation.
 Since this is a source you control, we can design it to fit the integration 
needs.
+
+The contract proposal will be created during design assembly. No artifact 
exists yet.
 ```
 
+Record status as "designed" with no artifact reference yet. The proposal will 
be carried into the design specification for approval.
+
+If field mapping is needed (Question 7a), it will be deferred until the design 
specification is approved and the proposed contract becomes available.
+
 Note: Only propose designing contracts for systems under your control. 
External system interfaces cannot be redesigned.
 
 **For "not applicable":**
@@ -269,8 +275,14 @@ I'll propose a [contract-type] definition based on your 
requirements.
 
 This will be included in the design specification for your approval before 
implementation.
 Since this is a destination you control, we can design it to fit the 
integration needs.
+
+The contract proposal will be created during design assembly. No artifact 
exists yet.
 ```
 
+Record status as "designed" with no artifact reference yet. The proposal will 
be carried into the design specification for approval.
+
+If field mapping is needed (Question 7a), it will be deferred until the design 
specification is approved and the proposed contract becomes available.
+
 Note: Only propose designing contracts for systems under your control. 
External system interfaces cannot be redesigned.
 
 **For "not applicable":**
@@ -360,19 +372,28 @@ ONLY if field mapping needed AND format pair is XML/JSON 
combinations.
 
 Before proceeding, determine which mappings can be collected now:
 
+**Contract status mapping decisions:**
+- **Status "existing" with artifact** - Proceed with mapping, pass artifact to 
DataMapper
+- **Status "designed" with artifact** - Proceed with mapping, pass artifact to 
DataMapper
+- **Status "designed" without artifact yet** - Defer mapping. Note: "Field 
mapping depends on [source/destination] contract design approval. Kit will 
propose schema in design spec."
+- **Status "pending"** - Defer mapping. Note: "Field mapping depends on 
pending [source/destination] contract"
+- **Status "not-applicable"** - Proceed with schema-less mapping (Groovy with 
manually described fields)
+
 **For single-destination flows:**
 - Check source contract (`flow.contracts.source` from Q7b) and destination 
contract (`flow.contracts.destination` from Q7c)
-- If BOTH source and destination have status "existing" or "designed", proceed 
with mapping
-- If EITHER source or destination has status "pending", defer this mapping. 
Note in design spec: "Field mapping depends on pending [source/destination] 
contract and will be resolved when the artifact arrives"
+- Apply above mapping decisions for each contract status
+- Proceed if BOTH endpoints allow mapping (existing with artifact, designed 
with artifact, or not-applicable)
+- Defer if EITHER endpoint requires deferral (pending or designed without 
artifact)
 
 **For conditional routing flows:**
 - Check source contract (`flow.contracts.source` from Q7b)
 - For EACH routing branch, check that branch's destination contract 
(`flow.routing.conditions[].contract` from Q8b)
-- Collect mapping for each branch where BOTH source and that branch's 
destination have status "existing" or "designed"
-- Defer mapping for branches where source or that specific branch's 
destination has status "pending"
-- Record each pending mapping dependency separately: "Field mapping for 
[branch-name] depends on pending [source/destination] contract"
+- Apply mapping decisions per branch
+- Collect mapping for each branch where BOTH source and destination allow 
mapping
+- Defer mapping for branches where either endpoint requires deferral
+- Record each deferred mapping dependency separately: "Field mapping for 
[branch-name] depends on [pending contract / design approval for contract]"
 
-If source contract is "pending", defer ALL mappings for this flow.
+If source contract is "pending" or "designed without artifact", defer ALL 
mappings for this flow.
 
 ```
 For the data transformation in "[flow-name]":
diff --git 
a/kit/camel-kit-core/src/main/resources/skills/camel-design/guides/datamapper-interview.md
 
b/kit/camel-kit-core/src/main/resources/skills/camel-design/guides/datamapper-interview.md
index e9102b62..f2f4b79d 100644
--- 
a/kit/camel-kit-core/src/main/resources/skills/camel-design/guides/datamapper-interview.md
+++ 
b/kit/camel-kit-core/src/main/resources/skills/camel-design/guides/datamapper-interview.md
@@ -27,13 +27,25 @@ Is this correct? (yes / no — specify the correct pair)
 
 ## Step 2: Source Schema
 
-**Check for existing artifact:** If `camel-brainstorm` Question 7b recorded a 
source contract with status "existing" or "designed", use that artifact 
reference. The contract includes:
-- Artifact location (file path, URL, or inline content)
-- Contract type (OpenAPI, AsyncAPI, WSDL, JSON Schema, XSD, other)
+**Check for existing artifact:** If `camel-brainstorm` Question 7b recorded a 
source contract, check the status and artifact:
 
-If a source schema artifact is already available, extract the schema from the 
artifact and skip the request below. For OpenAPI/AsyncAPI, extract the message 
schema. For WSDL, extract the message XSD. For JSON Schema/XSD, use as-is.
+- **Status "existing" with artifact** - Extract schema from artifact and skip 
request below
+- **Status "designed" with artifact** - Extract schema from artifact and skip 
request below
+- **Status "designed" without artifact** - This mapping should have been 
deferred by Q7a. If reached here, note error: mapping depends on design 
approval for proposed contract
+- **Status "not-applicable"** - Proceed with schema-less path (option c below)
+- **Status "pending"** - This mapping should have been deferred by Q7a
 
-**If no source schema artifact is available from Q7b, ask:**
+For artifacts with schemas:
+- **JSON Schema / XSD files** - Use file path as-is
+- **OpenAPI / AsyncAPI with embedded schema** - Extract message schema, save 
to `{flow-name}-source.schema.json` in project root, record this path
+- **WSDL with embedded XSD** - Extract XSD, save to `{flow-name}-source.xsd` 
in project root, record this path
+- **Inline content** - Save to `{flow-name}-source.{xsd|schema.json}` in 
project root, record this path
+
+Preserve schema references: if the extracted schema references other 
components in the original document (e.g., OpenAPI Order references OrderItem), 
save the complete schema with all referenced components to maintain validity.
+
+Skip request below after extracting and saving schema.
+
+**If no source schema artifact is available and status allows schema-less 
mapping, ask:**
 
 ```
 Please provide the source schema.
@@ -56,13 +68,25 @@ c) No schema — I'll describe the fields manually
 
 ## Step 3: Target Schema
 
-**Check for existing artifact:** If `camel-brainstorm` Question 7c 
(single-destination) or Question 8b (conditional routing branch) recorded a 
destination contract with status "existing" or "designed", use that artifact 
reference. The contract includes:
-- Artifact location (file path, URL, or inline content)
-- Contract type (OpenAPI, AsyncAPI, WSDL, JSON Schema, XSD, other)
+**Check for existing artifact:** If `camel-brainstorm` Question 7c 
(single-destination) or Question 8b (conditional routing branch) recorded a 
destination contract, check the status and artifact:
+
+- **Status "existing" with artifact** - Extract schema from artifact and skip 
request below
+- **Status "designed" with artifact** - Extract schema from artifact and skip 
request below  
+- **Status "designed" without artifact** - This mapping should have been 
deferred by Q7a. If reached here, note error: mapping depends on design 
approval for proposed contract
+- **Status "not-applicable"** - Proceed with schema-less path (option c below)
+- **Status "pending"** - This mapping should have been deferred by Q7a
+
+For artifacts with schemas:
+- **JSON Schema / XSD files** - Use file path as-is
+- **OpenAPI / AsyncAPI with embedded schema** - Extract message schema, save 
to `{flow-name}-target.schema.json` in project root, record this path
+- **WSDL with embedded XSD** - Extract XSD, save to `{flow-name}-target.xsd` 
in project root, record this path
+- **Inline content** - Save to `{flow-name}-target.{xsd|schema.json}` in 
project root, record this path
+
+Preserve schema references: if the extracted schema references other 
components in the original document, save the complete schema with all 
referenced components to maintain validity.
 
-If a target schema artifact is already available, extract the schema from the 
artifact and skip the request below. For OpenAPI/AsyncAPI, extract the message 
schema. For WSDL, extract the message XSD. For JSON Schema/XSD, use as-is.
+Skip request below after extracting and saving schema.
 
-**If no target schema artifact is available from Q7c/Q8b, ask:**
+**If no target schema artifact is available and status allows schema-less 
mapping, ask:**
 
 ```
 Please provide the target schema.
@@ -237,4 +261,4 @@ The shared guide will:
 
 **Schema-less path:** If source or target has no schema file (Step 2c or 3c 
selected), the type is still `JSON_SCHEMA` or `XML_SCHEMA` (based on the data 
format) — the schema path is `"none"`. Pass the manually described field names 
and types. The shared guide will compute XPaths from the field paths without 
needing schema files. Only use `Primitive` if the data is a truly scalar value 
(single string, number, or boolean).
 
-**When done:** return control to `camel-brainstorm` and continue at Question 8 
(Sink System).
+**When done:** return control to `camel-brainstorm` and continue at Question 9 
(Error Handling).
diff --git 
a/kit/camel-kit-core/src/test/java/org/apache/camel/kit/brainstorm/InterfaceContractDiscoveryTest.java
 
b/kit/camel-kit-core/src/test/java/org/apache/camel/kit/brainstorm/InterfaceContractDiscoveryTest.java
index c0c38c58..43ac662e 100644
--- 
a/kit/camel-kit-core/src/test/java/org/apache/camel/kit/brainstorm/InterfaceContractDiscoveryTest.java
+++ 
b/kit/camel-kit-core/src/test/java/org/apache/camel/kit/brainstorm/InterfaceContractDiscoveryTest.java
@@ -146,9 +146,9 @@ class InterfaceContractDiscoveryTest {
                 || q7aSection.contains("separately"),
                 "Question 7a must record each pending mapping dependency 
separately");
 
-        // Must defer all if source is pending
-        assertTrue(q7aSection.contains("If source contract is \"pending\", 
defer ALL"),
-                "Question 7a must defer all mappings if source contract is 
pending");
+        // Must defer all if source is pending or designed without artifact
+        assertTrue(q7aSection.contains("If source contract is \"pending\"") && 
q7aSection.contains("defer ALL"),
+                "Question 7a must defer all mappings if source contract is 
pending or designed without artifact");
     }
 
     @Test
@@ -476,6 +476,118 @@ class InterfaceContractDiscoveryTest {
                 "Briefing must list all supported contract types");
     }
 
+    @Test
+    @DisplayName("DataMapper must handle ready branch alongside pending 
branch")
+    void testDataMapperHandlesReadyAndPendingBranches() throws Exception {
+        Path interviewPath = Path.of(GREENFIELD_INTERVIEW_PATH);
+        String content = Files.readString(interviewPath);
+
+        int q7aIndex = content.indexOf("### Question 7a: Data Transformation 
Detail");
+        int q9Index = content.indexOf("### Question 9: Error Handling");
+        String q7aSection = content.substring(q7aIndex, q9Index);
+
+        // Must describe per-branch mapping collection
+        assertTrue(q7aSection.contains("Collect mapping for each branch 
where"),
+                "Q7a must describe collecting mapping for ready branches");
+
+        // Must defer only specific branches with pending dependencies
+        assertTrue(q7aSection.contains("Defer mapping for branches where"),
+                "Q7a must defer only branches with pending dependencies");
+
+        // Must allow not-applicable (schema-less mapping)
+        assertTrue(q7aSection.contains("not-applicable") && 
q7aSection.contains("schema-less"),
+                "Q7a must support not-applicable status for schema-less Groovy 
mapping");
+
+        // Must handle designed without artifact (defer until approval)
+        assertTrue(q7aSection.contains("designed without artifact") && 
q7aSection.contains("defer"),
+                "Q7a must defer mapping for designed contracts without 
artifacts (awaiting design approval)");
+    }
+
+    @Test
+    @DisplayName("DataMapper final exit must return to Q9")
+    void testDataMapperFinalExitReturnsToQ9() throws Exception {
+        Path datamapperPath = 
Path.of("src/main/resources/skills/camel-design/guides/datamapper-interview.md");
+        String content = Files.readString(datamapperPath);
+
+        // Find the final "When done" instruction
+        int whenDoneIndex = content.lastIndexOf("When done");
+        assertTrue(whenDoneIndex > 0, "DataMapper interview must have 'When 
done' instruction");
+
+        String whenDoneSection = content.substring(whenDoneIndex, 
Math.min(content.length(), whenDoneIndex + 200));
+
+        // Must return to Q9, not Q8
+        assertTrue(whenDoneSection.contains("Question 9"),
+                "DataMapper 'When done' instruction must return to Question 
9");
+        assertFalse(whenDoneSection.contains("Question 8"),
+                "DataMapper 'When done' instruction must NOT return to 
Question 8");
+    }
+
+    @Test
+    @DisplayName("DataMapper Steps 2-3 must handle designed contracts without 
artifacts")
+    void testDataMapperHandlesDesignedWithoutArtifact() throws Exception {
+        Path datamapperPath = 
Path.of("src/main/resources/skills/camel-design/guides/datamapper-interview.md");
+        String content = Files.readString(datamapperPath);
+
+        // Check Step 2
+        int step2Index = content.indexOf("## Step 2: Source Schema");
+        int step3Index = content.indexOf("## Step 3: Target Schema");
+        String step2Section = content.substring(step2Index, step3Index);
+
+        assertTrue(
+                step2Section.contains("\"designed\" without artifact")
+                        || step2Section.contains("designed without artifact"),
+                "Step 2 must check for designed status without artifact");
+        assertTrue(
+                step2Section.contains("should have been deferred")
+                        || step2Section.contains("depends on design approval"),
+                "Step 2 must note that designed-without-artifact should have 
been deferred by Q7a");
+
+        // Check Step 3
+        int step3bIndex = content.indexOf("## Step 3b:");
+        String step3Section = content.substring(step3Index, step3bIndex);
+
+        assertTrue(
+                step3Section.contains("\"designed\" without artifact")
+                        || step3Section.contains("designed without artifact"),
+                "Step 3 must check for designed status without artifact");
+        assertTrue(
+                step3Section.contains("should have been deferred")
+                        || step3Section.contains("depends on design approval"),
+                "Step 3 must note that designed-without-artifact should have 
been deferred by Q7a");
+    }
+
+    @Test
+    @DisplayName("DataMapper must save extracted schemas with paths and 
preserve references")
+    void testDataMapperSavesExtractedSchemas() throws Exception {
+        Path datamapperPath = 
Path.of("src/main/resources/skills/camel-design/guides/datamapper-interview.md");
+        String content = Files.readString(datamapperPath);
+
+        // Check Step 2 for extracted schema handling
+        int step2Index = content.indexOf("## Step 2: Source Schema");
+        int step3Index = content.indexOf("## Step 3: Target Schema");
+        String step2Section = content.substring(step2Index, step3Index);
+
+        assertTrue(step2Section.contains("Extract") && 
step2Section.contains("save to"),
+                "Step 2 must extract and save embedded schemas");
+        assertTrue(step2Section.contains("flow-name}-source") && 
step2Section.contains("record this path"),
+                "Step 2 must save extracted source schema with 
project-relative path");
+        assertTrue(
+                step2Section.contains("Preserve schema references") || 
step2Section.contains("referenced components"),
+                "Step 2 must preserve references in extracted schemas");
+
+        // Check Step 3
+        int step3bIndex = content.indexOf("## Step 3b:");
+        String step3Section = content.substring(step3Index, step3bIndex);
+
+        assertTrue(step3Section.contains("Extract") && 
step3Section.contains("save to"),
+                "Step 3 must extract and save embedded schemas");
+        assertTrue(step3Section.contains("flow-name}-target") && 
step3Section.contains("record this path"),
+                "Step 3 must save extracted target schema with 
project-relative path");
+        assertTrue(
+                step3Section.contains("Preserve schema references") || 
step3Section.contains("referenced components"),
+                "Step 3 must preserve references in extracted schemas");
+    }
+
     @Test
     @DisplayName("Interview contract questions must support all four answer 
options")
     void testContractQuestionsSupportAllOptions() throws Exception {

Reply via email to