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 60aa8afc57b2a90c6729117b351366c70eca3e75 Author: Jinal Sarvaiya <[email protected]> AuthorDate: Thu Nov 26 17:04:45 2026 +0000 Address maintainer review feedback --- .../camel/kit/ship/controller/ShipCoordinator.java | 20 +++++ .../camel-brainstorm/guides/design-assembly.md | 17 +++-- .../guides/greenfield-interview.md | 2 +- .../camel-design/guides/datamapper-interview.md | 2 +- .../skills/shared/datamapper-canonicalize.md | 10 ++- .../brainstorm/InterfaceContractDiscoveryTest.java | 85 +++++++++++++++++----- 6 files changed, 106 insertions(+), 30 deletions(-) diff --git a/kit/camel-kit-core/src/main/java/org/apache/camel/kit/ship/controller/ShipCoordinator.java b/kit/camel-kit-core/src/main/java/org/apache/camel/kit/ship/controller/ShipCoordinator.java index eeeded04..c2a8471e 100644 --- a/kit/camel-kit-core/src/main/java/org/apache/camel/kit/ship/controller/ShipCoordinator.java +++ b/kit/camel-kit-core/src/main/java/org/apache/camel/kit/ship/controller/ShipCoordinator.java @@ -978,6 +978,26 @@ public final class ShipCoordinator { .append(attempt.run().pipelineId()) .append(".\n"); } + prompt.append("For each integration boundary (source and destination), establish the ") + .append("interface contract status separately. Ask one boundary at a time. ") + .append("Analyze supplied material first—check if the user already provided ") + .append("OpenAPI, AsyncAPI, WSDL, JSON Schema, XSD, or documented message contract. ") + .append("If found, read it, extract constraints, record status as \"existing\", ") + .append("and skip the question for that boundary. ") + .append("Four possible statuses: ") + .append("(1) existing—request artifact, type, constraints; read and establish schema version, ") + .append("required vs. optional fields, data type constraints, breaking vs. non-breaking policies; ") + .append("(2) pending—record dependency, note field-level decisions remain open, do not invent placeholder, ") + .append("defer DataMapper or transformations that depend on this contract; ") + .append("(3) designed—propose contract based on requirements, include in design spec for approval, ") + .append("only for user-controlled endpoints, never redesign external interfaces; ") + .append("(4) not-applicable—record rationale, no further action. ") + .append("Capture separately for source and destination: status, artifact, type, constraints, dependencies. ") + .append("For conditional routing, record one contract per distinct target. ") + .append("Record all findings in the report field. Record every unresolved contract question ") + .append("in unansweredQuestions with the default applied or null if none. ") + .append("Use the grouped report structure: analyzed material, established contracts, ") + .append("pending contracts, designed contracts, not-applicable contracts.\n"); } case DESIGN -> prompt.append( "Produce the complete Camel integration design. " 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 8e5399b3..05c974b2 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 @@ -508,14 +508,21 @@ Fix any issues inline. 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 + - **Recheck that BOTH endpoints are now ready** using Q7a's readiness rule: + - Proceed if BOTH source and destination allow mapping (status "existing" with artifact, "designed" with artifact, or "not-applicable") + - Keep the mapping deferred if EITHER endpoint still requires deferral (status "pending" or "designed" without artifact yet) + - For mappings where both endpoints are now ready: + - 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 + - For mappings still deferred (e.g., pending source, designed destination): + - Leave the mapping deferred and note the remaining dependency in the spec This ensures: - User approves both the proposed contract AND the mapping that uses it -- Implementation has the complete canonical mapping section +- Mappings with unresolved dependencies remain deferred until all contracts are available +- Implementation has the complete canonical mapping section for resolved mappings - 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. 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 48528bef..e6710e9a 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 @@ -414,7 +414,7 @@ Load `camel-design/guides/datamapper-interview.md` and `shared/datamapper-canoni Record: `flow.datamapper.mappings[]` -After completing DataMapper (or noting deferred mappings), return to Question 9. +After completing DataMapper (or noting deferred mappings), continue to Question 9 (Error Handling). ### Question 9: Error Handling (per flow) 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 0383a29c..90e29abc 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 @@ -270,4 +270,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 9 (Error Handling). +**When done:** return control to the calling guide. The calling guide determines the next step. diff --git a/kit/camel-kit-core/src/main/resources/skills/shared/datamapper-canonicalize.md b/kit/camel-kit-core/src/main/resources/skills/shared/datamapper-canonicalize.md index e8a32715..285e9b5b 100644 --- a/kit/camel-kit-core/src/main/resources/skills/shared/datamapper-canonicalize.md +++ b/kit/camel-kit-core/src/main/resources/skills/shared/datamapper-canonicalize.md @@ -303,9 +303,10 @@ Omit the Collection Mappings section if there are no collection mappings. ## Step 6: Return Control -**When done:** return control to the calling guide. +**When done:** return control to the calling guide. The calling guide determines the next step. -- If called from `datamapper-interview.md`: return to `camel-brainstorm` at Question 9 (Error Handling). +- If called from `datamapper-interview.md` during greenfield interview (Q7a): the interview continues at Question 9 (Error Handling). +- If called from `datamapper-interview.md` during design assembly: control returns to design assembly to collect the mapping. - If called from `datamapper-migrate.md`: return to `camel-migrate-mule` Step 2.3. --- @@ -444,7 +445,8 @@ Omit the Collection Mappings section if there are no collection mappings. ## Step 4G: Return Control -**When done:** return control to the calling guide. +**When done:** return control to the calling guide. The calling guide determines the next step. -- If called from `datamapper-interview.md`: return to `camel-brainstorm` at Question 9 (Error Handling). +- If called from `datamapper-interview.md` during greenfield interview (Q7a): the interview continues at Question 9 (Error Handling). +- If called from `datamapper-interview.md` during design assembly: control returns to design assembly to collect the mapping. - If called from `datamapper-migrate.md`: return to `camel-migrate-mule` Step 2.3. 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 2f96dd77..699ad593 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 @@ -180,9 +180,9 @@ class InterfaceContractDiscoveryTest { || q7aSection.contains("not already available"), "Question 7a must ask only for information not already in contract artifacts"); - // Must return to Question 9 - assertTrue(q7aSection.contains("return to Question 9"), - "Question 7a must explicitly return to Question 9 after completion"); + // Must continue to Question 9 after DataMapper returns + assertTrue(q7aSection.contains("continue to Question 9"), + "Question 7a must continue to Question 9 after DataMapper returns control"); } @Test @@ -238,9 +238,12 @@ class InterfaceContractDiscoveryTest { String content = Files.readString(canonicalizePath); - // Must return to Question 9, not Question 8 - assertTrue(content.contains("return to `camel-brainstorm` at Question 9"), - "DataMapper canonicalize must return to Question 9"); + // Must return to calling guide, and when called from greenfield interview, continues to Q9 + assertTrue(content.contains("return control to the calling guide"), + "DataMapper canonicalize must return control to the calling guide"); + + assertTrue(content.contains("greenfield interview") && content.contains("Question 9"), + "DataMapper canonicalize must specify that greenfield interview continues to Question 9"); assertFalse(content.contains("return to `camel-brainstorm` at Question 8"), "DataMapper canonicalize must NOT return to Question 8"); @@ -504,7 +507,7 @@ class InterfaceContractDiscoveryTest { } @Test - @DisplayName("DataMapper final exit must return to Q9") + @DisplayName("DataMapper final exit must return to calling guide") void testDataMapperFinalExitReturnsToQ9() throws Exception { Path datamapperPath = Path.of("src/main/resources/skills/camel-design/guides/datamapper-interview.md"); String content = Files.readString(datamapperPath); @@ -515,9 +518,9 @@ class InterfaceContractDiscoveryTest { 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"); + // Must return to calling guide + assertTrue(whenDoneSection.contains("calling guide"), + "DataMapper 'When done' instruction must return to calling guide"); assertFalse(whenDoneSection.contains("Question 8"), "DataMapper 'When done' instruction must NOT return to Question 8"); } @@ -697,24 +700,68 @@ class InterfaceContractDiscoveryTest { 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 have template with branch identifier placeholder + assertTrue(step3Section.contains("{flow-name}-{branch-identifier}-target"), + "Step 3 must specify filename template with branch identifier placeholder"); // 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"); + // Must show actual distinct complete filenames in examples + assertTrue(step3Section.contains("orders-billing-target.schema.json") + && step3Section.contains("orders-warehouse-target.schema.json"), + "Step 3 must show billing and warehouse examples with complete distinct filenames"); + + // Verify they are different paths (not accidentally the same) + int billingIndex = step3Section.indexOf("orders-billing-target.schema.json"); + int warehouseIndex = step3Section.indexOf("orders-warehouse-target.schema.json"); + assertTrue(billingIndex >= 0 && warehouseIndex >= 0 && billingIndex != warehouseIndex, + "billing and warehouse must be distinct paths at different positions"); + } + + @Test + @DisplayName("Ship DISCOVERY task must contain contract rules in issued prompt") + void testShipDiscoveryPromptContainsRules() throws Exception { + Path shipCoordinatorPath = Path.of(SHIP_COORDINATOR_PATH); + String content = Files.readString(shipCoordinatorPath); + + // Find the prompt() method DISCOVERY case + int promptMethodIndex = content.indexOf("private String prompt("); + int discoveryIndex = content.indexOf("case DISCOVERY ->", promptMethodIndex); + int designIndex = content.indexOf("case DESIGN ->", discoveryIndex); + + assertTrue(discoveryIndex > 0 && designIndex > discoveryIndex, + "Ship prompt method must have DISCOVERY case"); + + String discoveryCase = content.substring(discoveryIndex, designIndex); + + // Must have contract rules in the DISCOVERY task itself, not just briefing + assertTrue(discoveryCase.contains("interface contract"), + "DISCOVERY task must mention interface contract"); + + assertTrue(discoveryCase.contains("existing") && discoveryCase.contains("pending") + && discoveryCase.contains("designed") && discoveryCase.contains("not-applicable"), + "DISCOVERY task must list all four contract statuses"); + + assertTrue(discoveryCase.contains("prompt.append") && discoveryCase.contains("boundary"), + "DISCOVERY task must append contract boundary rules to prompt"); + + // Must reference report and unansweredQuestions structure + assertTrue(discoveryCase.contains("report") && discoveryCase.contains("unansweredQuestions"), + "DISCOVERY task must specify where to record contract findings"); + + // Verify these rules are in the issued prompt, not in briefing() method + int briefingMethodIndex = content.indexOf("private Path briefing("); + int promptMethodEndIndex = content.indexOf("private", promptMethodIndex + 1); + + // Rules should be in prompt() method range, not before it + assertTrue(discoveryIndex > promptMethodIndex && discoveryIndex < promptMethodEndIndex, + "Contract rules must be in prompt() method (issued task), not just briefing"); } }
