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 9ccd6ba869cee2801184e6fa4bd9866cbe4c3974 Author: Jinal Sarvaiya <[email protected]> AuthorDate: Thu Nov 26 15:49:13 2026 +0000 Address maintainer review --- .../camel-brainstorm/guides/design-assembly.md | 18 ++++ .../camel-design/guides/datamapper-interview.md | 15 +++- .../brainstorm/InterfaceContractDiscoveryTest.java | 96 ++++++++++++++++++++++ 3 files changed, 126 insertions(+), 3 deletions(-) diff --git a/kit/camel-kit-core/src/main/resources/skills/camel-brainstorm/guides/design-assembly.md b/kit/camel-kit-core/src/main/resources/skills/camel-brainstorm/guides/design-assembly.md index 2c71e772..8e5399b3 100644 --- a/kit/camel-kit-core/src/main/resources/skills/camel-brainstorm/guides/design-assembly.md +++ b/kit/camel-kit-core/src/main/resources/skills/camel-brainstorm/guides/design-assembly.md @@ -502,6 +502,24 @@ Fix any issues inline. ``` 3. Copy `templates/constitution.md` to `docs/constitution.md` if it doesn't exist +## Collect Deferred Mappings for Designed Contracts + +**Before presenting the design for approval**, check if any field mappings were deferred because contracts had status "designed" without artifacts: + +1. Review the interview record for any deferred mappings with reason: "depends on [source/destination] contract design approval" +2. For each deferred mapping: + - The proposed contract is now in the design spec (Section 3 flow designs) + - Load `camel-design/guides/datamapper-interview.md` with the proposed contract as the artifact + - Collect the field mapping against the proposed schema + - Insert the completed mapping into the design spec before approval + +This ensures: +- User approves both the proposed contract AND the mapping that uses it +- Implementation has the complete canonical mapping section +- No transformations are lost due to missing mapping sections + +If no mappings were deferred for designed contracts, skip this step and proceed to present the spec. + Present the spec to the user: ``` 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 f2f4b79d..0383a29c 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 @@ -78,12 +78,21 @@ c) No schema — I'll describe the fields manually 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 +- **OpenAPI / AsyncAPI with embedded schema** - Extract message schema, save to unique path (see below), record this path +- **WSDL with embedded XSD** - Extract XSD, save to unique path (see below), record this path +- **Inline content** - Save to unique path (see below), record this path + +**Unique path generation for extracted/inline schemas:** +- **Single-destination flow** - Use `{flow-name}-target.schema.json` or `{flow-name}-target.xsd` +- **Conditional routing (multiple branches)** - Use `{flow-name}-{branch-identifier}-target.schema.json` or `{flow-name}-{branch-identifier}-target.xsd` + - Branch identifier: use routing condition name (e.g., "billing", "warehouse") or branch index (e.g., "branch1", "branch2") + - Each destination's schema gets its own file to prevent overwriting + - Example: `orders-billing-target.schema.json`, `orders-warehouse-target.schema.json` 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. +Carry the exact recorded path into the mapping specification so each branch references its correct schema file. + Skip request below after extracting and saving schema. **If no target schema artifact is available and status allows schema-less mapping, ask:** 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 43ac662e..2f96dd77 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 @@ -621,4 +621,100 @@ class InterfaceContractDiscoveryTest { assertTrue(q7cSection.contains("Not applicable"), "Question 7c must have 'not-applicable' option"); } + + @Test + @DisplayName("Q7a must proceed when BOTH endpoints ready, defer when EITHER pending") + void testDataMapperBranchSelectionLogic() 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 proceeding when BOTH are ready + assertTrue( + q7aSection.contains("BOTH source and destination") + || q7aSection.contains("BOTH source and that branch"), + "Q7a must check that BOTH endpoints are ready before proceeding"); + + assertTrue(q7aSection.contains("existing\" with artifact") || q7aSection.contains("designed\" with artifact"), + "Q7a must specify ready states: existing with artifact or designed with artifact"); + + // Must describe deferring when EITHER is not ready + assertTrue(q7aSection.contains("EITHER") || q7aSection.contains("Defer if EITHER"), + "Q7a must defer if EITHER endpoint is not ready"); + + assertTrue(q7aSection.contains("\"pending\"") && q7aSection.contains("defer"), + "Q7a must defer mappings when either endpoint has pending status"); + + assertTrue(q7aSection.contains("\"designed\" without artifact") && q7aSection.contains("defer"), + "Q7a must defer mappings when either endpoint has designed status without artifact"); + + // Must NOT have inverted logic like "proceed when both pending" or "defer when both ready" + String q7aLower = q7aSection.toLowerCase(); + assertFalse(q7aLower.contains("proceed when both pending") + || q7aLower.contains("proceed if both pending") + || q7aLower.contains("both pending") && q7aLower.contains(" proceed"), + "Q7a must NOT proceed when both endpoints are pending (inverted logic check)"); + } + + @Test + @DisplayName("Design assembly must collect deferred mappings before approval") + void testDesignAssemblyCollectsDeferredMappings() throws Exception { + Path designAssemblyPath = Path.of("src/main/resources/skills/camel-brainstorm/guides/design-assembly.md"); + assertTrue(Files.exists(designAssemblyPath), "Design assembly guide must exist"); + + String content = Files.readString(designAssemblyPath); + + // Must have section about collecting deferred mappings + assertTrue(content.contains("Collect Deferred Mappings") || content.contains("deferred mappings"), + "Design assembly must have instructions for collecting deferred mappings"); + + // Must check for deferred mappings before approval + int approvalIndex = content.indexOf("Do you approve this design"); + assertTrue(approvalIndex > 0, "Design assembly must have approval question"); + + String beforeApproval = content.substring(0, approvalIndex); + assertTrue(beforeApproval.contains("deferred") && beforeApproval.contains("designed"), + "Design assembly must check for deferred mappings before approval"); + + assertTrue(beforeApproval.contains("Load") && beforeApproval.contains("datamapper-interview.md"), + "Design assembly must load DataMapper to collect deferred mappings"); + + // Must ensure mappings are in design spec before approval + assertTrue(beforeApproval.contains("canonical mapping section") || beforeApproval.contains("complete"), + "Design assembly must ensure implementation has complete mapping section"); + } + + @Test + @DisplayName("DataMapper target schema paths must be unique per routing branch") + void testDataMapperUniqueTargetPathsPerBranch() throws Exception { + Path datamapperPath = Path.of("src/main/resources/skills/camel-design/guides/datamapper-interview.md"); + String content = Files.readString(datamapperPath); + + int step3Index = content.indexOf("## Step 3: Target Schema"); + int step3bIndex = content.indexOf("## Step 3b:"); + String step3Section = content.substring(step3Index, step3bIndex); + + // Must describe unique path generation + assertTrue(step3Section.contains("Unique path") || step3Section.contains("unique path"), + "Step 3 must describe unique path generation for target schemas"); + + // Must handle conditional routing with branch identifiers + assertTrue(step3Section.contains("Conditional routing") || step3Section.contains("multiple branches"), + "Step 3 must handle conditional routing case"); + + assertTrue(step3Section.contains("branch-identifier") || step3Section.contains("branch identifier"), + "Step 3 must use branch identifier in filenames"); + + // Must prevent overwriting + assertTrue(step3Section.contains("prevent overwriting") || step3Section.contains("gets its own file"), + "Step 3 must prevent one branch's schema from overwriting another's"); + + // Must give example with multiple distinct filenames + assertTrue(step3Section.contains("billing") && step3Section.contains("warehouse"), + "Step 3 must show example with distinct branch filenames"); + } + }
