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 bf97c04ad18813db040298dcbbdffd20c34c632e Author: Jinal Sarvaiya <[email protected]> AuthorDate: Fri Nov 27 09:45:35 2026 +0000 Address review --- .../camel/kit/ship/controller/ShipCoordinator.java | 53 ------- .../guides/greenfield-interview.md | 6 +- .../camel-design/guides/datamapper-interview.md | 2 +- .../brainstorm/InterfaceContractDiscoveryTest.java | 157 ++++++++++++++------- 4 files changed, 109 insertions(+), 109 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 c2a8471e..b213a8fe 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 @@ -738,59 +738,6 @@ public final class ShipCoordinator { } } - // For DISCOVERY stage, include interface contract discovery rules directly in prompt - if (attempt.stage().stage() == Stage.DISCOVERY) { - text.append("\n## Interface Contract Discovery\n\n") - .append("For each integration boundary (source and destination), establish the ") - .append("interface contract status separately:\n\n") - .append("### Ask One Boundary at a Time\n\n") - .append("1. **For the source** (where data comes from): Do you have an interface ") - .append("definition, will you provide one later, should we design it, or is it not applicable?\n") - .append("2. **For the destination** (where data goes): Do you have an interface ") - .append("definition, will you provide one later, should we design it, or is it not applicable?\n\n") - .append("### Analyze Supplied Material First\n\n") - .append("Before asking about a boundary's contract, check if the user already provided:\n") - .append("- OpenAPI specification\n") - .append("- AsyncAPI specification\n") - .append("- WSDL document\n") - .append("- JSON Schema\n") - .append("- XSD schema\n") - .append("- Documented message contract\n\n") - .append("If found, read it, extract constraints, record status as \"existing\", ") - .append("and skip the question for that boundary.\n\n") - .append("### Four Possible Statuses\n\n") - .append("**Status: existing** - Request artifact details (file path, URL, or inline content), ") - .append("contract type (OpenAPI/AsyncAPI/WSDL/JSON Schema/XSD/other), and compatibility constraints. ") - .append("Read and establish: schema version, required vs. optional fields, data type constraints, ") - .append("breaking vs. non-breaking policies. Record the artifact reference and all constraints.\n\n") - .append("**Status: pending** - Record dependency: \"[source/destination] contract must be provided ") - .append("before execution.\" Note: \"Detailed field-level design decisions remain open.\" ") - .append("Do NOT invent a placeholder contract. Defer DataMapper or field-level transformations ") - .append("that depend on this contract.\n\n") - .append("**Status: designed** - Propose contract definition based on requirements. Include in ") - .append("design specification for user approval before implementation. ONLY for user-controlled ") - .append("endpoints (never redesign external system interfaces). Specify contract type and present ") - .append("proposed schema.\n\n") - .append("**Status: not-applicable** - Record rationale for why no formal contract is needed. ") - .append("No further action required for this boundary.\n\n") - .append("### Record Both Boundaries\n\n") - .append("Capture separately:\n") - .append("- `source`: status, artifact, type, constraints, dependencies\n") - .append("- `destination`: status, artifact, type, constraints, dependencies\n\n") - .append("For conditional routing with multiple destinations, record one contract decision ") - .append("per distinct routing target.\n\n") - .append("### Recording in Ship Result\n\n") - .append("Record all interface contract findings in the `report` field of your result.\n") - .append("For each unresolved contract question, record it in `unansweredQuestions`.\n\n") - .append("Use the grouped `report` structure to capture:\n") - .append("- Analyzed material (what contracts were found in supplied requirements)\n") - .append("- Established contracts (status: existing, with artifact reference and constraints)\n") - .append("- Pending contracts (status: pending, with explicit dependency statement)\n") - .append("- Designed contracts (status: designed, with proposed schema for approval)\n") - .append("- Not applicable contracts (status: not-applicable, with rationale)\n\n"); - requireBriefingSize(text); - } - for (Stage stage : Stage.values()) { if (stage.ordinal() >= attempt.stage().stage().ordinal()) { break; 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 e6710e9a..9d157d16 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 @@ -217,7 +217,7 @@ The contract proposal will be created during design assembly. No artifact exists 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. +If field mapping is needed (Question 7a), it will be deferred until the proposed contract is available during design assembly. The mapping will remain deferred if the other endpoint is still pending at that time. Note: Only propose designing contracts for systems under your control. External system interfaces cannot be redesigned. @@ -230,7 +230,7 @@ Record: `flow.contracts.source` with status (existing/pending/designed/na), arti ### Question 7c: Destination Interface Contract (per flow) -Analyze supplied material first. If the user already provided a destination contract artifact, read it, record status as "existing", extract constraints, and skip this question for the destination. +Analyze supplied material first. If the user already provided a destination contract artifact, read it, record the status as "existing", extract constraints, and skip this question for the destination. ``` For flow "[flow-name]" destination (where data goes): @@ -281,7 +281,7 @@ The contract proposal will be created during design assembly. No artifact exists 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. +If field mapping is needed (Question 7a), it will be deferred until the proposed contract is available during design assembly. The mapping will remain deferred if the other endpoint is still pending at that time. Note: Only propose designing contracts for systems under your control. External system interfaces cannot be redesigned. 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 90e29abc..bf8994d5 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 @@ -9,7 +9,7 @@ You are now acting as a **Data Mapping Specialist**. This guide is loaded by `ca **Contract artifact references:** `camel-brainstorm` Question 7a passes any existing contract artifacts from Questions 7b, 7c, and 8b. Check for these references before asking for schemas in Steps 2-3. -Follow the steps below, then return control to `camel-brainstorm` at Question 9. +Follow the steps below, then return control to the calling guide. --- 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 699ad593..92f0cd6d 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 @@ -225,9 +225,9 @@ class InterfaceContractDiscoveryTest { assertTrue(step3Section.contains("skip the request") || step3Section.contains("skip"), "Step 3 must skip schema request if artifact is available"); - // Must return to Question 9 - assertTrue(content.contains("return control to `camel-brainstorm` at Question 9"), - "DataMapper interview must return to Question 9"); + // Must return to calling guide + assertTrue(content.contains("return control to the calling guide"), + "DataMapper interview must return control to the calling guide"); } @Test @@ -313,21 +313,19 @@ class InterfaceContractDiscoveryTest { assertTrue(content.contains("Stage.DISCOVERY"), "ShipCoordinator must have DISCOVERY stage handling"); - // Rules must be inline in text.append() calls - assertTrue(content.contains("Interface Contract Discovery"), - "DISCOVERY prompt must contain Interface Contract Discovery heading"); + // Rules must be in prompt.append() calls in the DISCOVERY case (not text.append in briefing) + assertTrue(content.contains("Ask one boundary at a time") && content.contains("prompt.append"), + "DISCOVERY case must append 'Ask one boundary at a time' rule to prompt"); - assertTrue(content.contains("Ask One Boundary") && content.contains("text.append"), - "DISCOVERY prompt must contain inline 'Ask One Boundary at a Time' rule"); + assertTrue(content.contains("Analyze supplied material first") && content.contains("prompt.append"), + "DISCOVERY case must append 'Analyze supplied material first' rule to prompt"); - assertTrue(content.contains("Analyze Supplied Material") && content.contains("text.append"), - "DISCOVERY prompt must contain inline 'Analyze Supplied Material First' rule"); + assertTrue(content.contains("Four possible statuses") && content.contains("prompt.append"), + "DISCOVERY case must append 'Four possible statuses' rule to prompt"); - assertTrue(content.contains("Four Possible Statuses") && content.contains("text.append"), - "DISCOVERY prompt must contain inline 'Four Possible Statuses' rule"); - - assertTrue(content.contains("Status: existing") && content.contains("Status: pending"), - "DISCOVERY prompt must define status values inline"); + assertTrue(content.contains("(1) existing") && content.contains("(2) pending") + && content.contains("(3) designed") && content.contains("(4) not-applicable"), + "DISCOVERY case must define all four status values in prompt"); } @Test @@ -338,15 +336,16 @@ class InterfaceContractDiscoveryTest { assertTrue(content.contains("Stage.DISCOVERY"), "DISCOVERY stage handling must exist"); - // Must tell worker to record in report and unansweredQuestions - assertTrue(content.contains("report") && content.contains("unansweredQuestions"), - "DISCOVERY prompt must mention 'report' and 'unansweredQuestions' fields"); + // Must tell worker to record in prompt (not briefing) + assertTrue(content.contains("prompt.append") && content.contains("report") + && content.contains("unansweredQuestions"), + "DISCOVERY case must tell worker to use report and unansweredQuestions fields in prompt"); - assertTrue(content.contains("Record all interface contract findings"), - "DISCOVERY prompt must instruct to record contract findings"); + assertTrue(content.contains("Record all findings in the report field"), + "DISCOVERY case must instruct to record findings in report field in prompt"); - assertTrue(content.contains("Recording in Ship Result") || content.contains("Recording"), - "DISCOVERY prompt must have recording instructions section"); + assertTrue(content.contains("grouped report structure"), + "DISCOVERY case must specify grouped report structure in prompt"); } @Test @@ -700,9 +699,11 @@ class InterfaceContractDiscoveryTest { int step3bIndex = content.indexOf("## Step 3b:"); String step3Section = content.substring(step3Index, step3bIndex); - // 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 have both JSON and XSD templates with branch identifier placeholder + assertTrue(step3Section.contains("{flow-name}-{branch-identifier}-target.schema.json"), + "Step 3 must specify JSON filename template with branch identifier placeholder"); + assertTrue(step3Section.contains("{flow-name}-{branch-identifier}-target.xsd"), + "Step 3 must specify XSD filename template with branch identifier placeholder"); // Must handle conditional routing with branch identifiers assertTrue(step3Section.contains("Conditional routing") || step3Section.contains("multiple branches"), @@ -712,16 +713,23 @@ class InterfaceContractDiscoveryTest { assertTrue(step3Section.contains("prevent overwriting") || step3Section.contains("gets its own file"), "Step 3 must prevent one branch's schema from overwriting another's"); - // 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"); + // Must show actual distinct complete filenames for JSON in examples + assertTrue(step3Section.contains("orders-billing-target.schema.json"), + "Step 3 must show billing example with complete JSON filename"); + assertTrue(step3Section.contains("orders-warehouse-target.schema.json"), + "Step 3 must show warehouse example with complete JSON filename"); + + // Verify JSON filenames are different (not accidentally the same) + int billingJsonIndex = step3Section.indexOf("orders-billing-target.schema.json"); + int warehouseJsonIndex = step3Section.indexOf("orders-warehouse-target.schema.json"); + assertTrue(billingJsonIndex >= 0 && warehouseJsonIndex >= 0 && billingJsonIndex != warehouseJsonIndex, + "billing and warehouse JSON filenames must be distinct at different positions"); + + // Both JSON and XSD examples must maintain branch identifier + assertTrue(step3Section.contains("branch-identifier") && step3Section.contains(".schema.json"), + "JSON template must maintain branch-identifier placeholder"); + assertTrue(step3Section.contains("branch-identifier") && step3Section.contains(".xsd"), + "XSD template must maintain branch-identifier placeholder"); } @Test @@ -740,28 +748,73 @@ class InterfaceContractDiscoveryTest { 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"); + // Must have specific contract rule text appended to prompt in DISCOVERY case + assertTrue(discoveryCase.contains("For each integration boundary (source and destination), establish the") + && discoveryCase.contains("interface contract status separately"), + "DISCOVERY case must append contract boundary text to prompt"); + + assertTrue(discoveryCase.contains("Ask one boundary at a time"), + "DISCOVERY case must append one-at-a-time instruction to prompt"); + + // Must list all four statuses with their rules in the prompt + assertTrue(discoveryCase.contains("(1) existing") && discoveryCase.contains("request artifact"), + "DISCOVERY case must append existing status rules to prompt"); + assertTrue(discoveryCase.contains("(2) pending") && discoveryCase.contains("defer DataMapper"), + "DISCOVERY case must append pending status rules to prompt"); + assertTrue(discoveryCase.contains("(3) designed") && discoveryCase.contains("only for user-controlled"), + "DISCOVERY case must append designed status rules to prompt"); + assertTrue(discoveryCase.contains("(4) not-applicable") && discoveryCase.contains("record rationale"), + "DISCOVERY case must append not-applicable status rules to prompt"); + + // Must reference report structure in prompt + assertTrue(discoveryCase.contains("grouped report structure") + && discoveryCase.contains("analyzed material"), + "DISCOVERY case must append report structure to prompt"); + + // Verify prompt.append is used (not a separate variable) + assertTrue(discoveryCase.contains("prompt.append(\"For each integration boundary"), + "DISCOVERY case must append to the prompt variable, not a copy"); + } - assertTrue(discoveryCase.contains("existing") && discoveryCase.contains("pending") - && discoveryCase.contains("designed") && discoveryCase.contains("not-applicable"), - "DISCOVERY task must list all four contract statuses"); + @Test + @DisplayName("Q7b and Q7c must check supplied material before asking (issue #111)") + void testContractQuestionsCheckSuppliedMaterialFirst() throws Exception { + Path interviewPath = Path.of(GREENFIELD_INTERVIEW_PATH); + String content = Files.readString(interviewPath); + + // Find Q7b (source contract) + int q7bIndex = content.indexOf("### Question 7b: Source Interface Contract"); + int q7cIndex = content.indexOf("### Question 7c: Destination Interface Contract"); + String q7bSection = content.substring(q7bIndex, q7cIndex); - assertTrue(discoveryCase.contains("prompt.append") && discoveryCase.contains("boundary"), - "DISCOVERY task must append contract boundary rules to prompt"); + // Q7b must analyze supplied material FIRST + assertTrue(q7bSection.contains("Analyze supplied material first"), + "Q7b must analyze supplied material before asking"); + assertTrue(q7bSection.contains("already provided") && q7bSection.contains("skip this question"), + "Q7b must skip question if contract already supplied"); - // Must reference report and unansweredQuestions structure - assertTrue(discoveryCase.contains("report") && discoveryCase.contains("unansweredQuestions"), - "DISCOVERY task must specify where to record contract findings"); + // Must list what to look for + assertTrue(q7bSection.contains("OpenAPI") && q7bSection.contains("AsyncAPI") + && q7bSection.contains("WSDL") && q7bSection.contains("JSON Schema"), + "Q7b must list contract types to look for in supplied material"); - // 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); + // Must record as "existing" when found, not ask + assertTrue(q7bSection.contains("record the status as \"existing\"") + && q7bSection.contains("skip this question"), + "Q7b must record existing and skip when contract is found"); - // 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"); + // Find Q7c (destination contract) + int q8Index = content.indexOf("### Question 8: Sink System"); + String q7cSection = content.substring(q7cIndex, q8Index); + + // Q7c must also analyze supplied material FIRST + assertTrue(q7cSection.contains("Analyze supplied material first"), + "Q7c must analyze supplied material before asking"); + assertTrue(q7cSection.contains("already provided") && q7cSection.contains("skip this question"), + "Q7c must skip question if contract already supplied"); + assertTrue(q7cSection.contains("record the status as \"existing\"") + && q7cSection.contains("skip this question"), + "Q7c must record existing and skip when contract is found"); } }
