SEZ9 opened a new pull request, #13425:
URL: https://github.com/apache/seatunnel/pull/13425

   Yes — glad to contribute this to Apache SeaTunnel.
   
   Closes #13416.
   
   ### What Problem Does This PR Solve?
   
   The engine's verdict on a config could not change the outcome.
   
   In the validation loop, `seatunnel.sh --check` ran only **after** the LLM 
validator had already passed the config, and its result became a footnote:
   
   ```python
   if validation.startswith("PASS"):
       dryrun = dry_run_config(config)
       dryrun_note = ""
       if dryrun["phase2_check"] and dryrun["phase2_check"] != "PASS":
           dryrun_note = f"\n\n**Dry-run note:** {dryrun['phase2_check']}"
       ...
       return {"type": "config", ...}          # delivered either way
   ```
   
   Two consequences:
   
   1. A config the engine **rejected** was returned with `"type": "config"`, 
exactly like one it accepted. The only check that actually loads the config and 
resolves plugins could not stop delivery.
   2. `_run_fix()` was only ever called with the LLM validator's text. The 
structured engine result was never passed to repair, so an engine error could 
not drive a fix even when it was the only thing that detected the problem.
   
   This also contradicted the documented contract. `docs/en/ai-cli/design.md` 
already states:
   
   > **Validate deterministically, repair with the LLM**: verdicts come from 
parsers and the engine; the LLM's job is generation and repair, never judging 
correctness.
   
   This PR makes the code match that for the engine side; it does not introduce 
a new policy.
   
   ### What Changed
   
   - An engine rejection is fed into the repair loop carrying the engine's own 
error text, instead of being appended to the explanation.
   - The best-effort exit after the repair budget is exhausted reports the 
unresolved failure instead of the blanket `Config generated (validation had 
warnings)`, and attaches the last engine result as `last_dry_run`.
   
   **The gate is deliberately narrow.** `phase2_check` has four shapes and they 
do not mean the same thing:
   
   | `phase2_check` | meaning | treated as rejection? |
   | --- | --- | --- |
   | `None` | no engine on this host, nothing was checked | **no** |
   | `"PASS"` | the engine loaded the config | no |
   | `"FAIL: <stderr>"` | the engine rejected the config | **yes** |
   | `"TIMEOUT (30s)"` / `"ERROR: <exc>"` | the check could not be completed | 
**no** |
   
   Only the explicit `FAIL` counts, via a new `_engine_rejection()` helper. 
Gating on "anything that is not PASS" — which is what the old note condition 
did — would push a perfectly good config into a rewrite because a subprocess 
timed out, and would stop every host without the engine installed from ever 
receiving a config.
   
   ### How Was This Patch Tested?
   
   `seatunnel-cli` suite: **441 passed** (431 before, 10 added), `ruff check .` 
clean.
   
   The tests are load-bearing in both directions — I checked that the obvious 
wrong implementations are caught, not just that the right one passes:
   
   | Mutation | Result |
   | --- | --- |
   | drop the gate (deliver with a note again) | 3 failed — 
`..._repaired_instead_of_delivered`, `..._given_the_engine_error_itself`, 
`..._reported_not_called_a_warning` |
   | widen the gate to `check != "PASS"` | 2 failed — 
`..._could_not_run_is_not_a_rejection`, `..._timed_out_does_not_trigger_repair` 
|
   | neither | 10 passed |
   
   New file `tests/test_orchestrator_dryrun_gate.py`, following this repo's 
one-file-per-concern pattern for orchestrator behaviour 
(`test_orchestrator_empty_plan.py`, 
`test_orchestrator_clarification_rounds.py`):
   
   - all four `phase2_check` shapes classified correctly
   - a rejected config is repaired, and the repaired one is delivered
   - the repair prompt contains the engine's error text
   - an accepted config is delivered with no repair
   - **a host without the engine still gets its config** (no repair triggered)
   - a check that timed out does not trigger repair, and the note still surfaces
   - an unresolved rejection is reported rather than described as a warning
   
   ### Compatibility
   
   - No new or changed configuration options, no changed defaults.
   - `"type": "config"` is still returned on the best-effort path, so `cli.py` 
and the benchmark runner keep working unchanged; only `content` is more 
specific. `last_dry_run` is additive and read with `.get()` where consumed.
   - The behaviour change is confined to configs the engine explicitly rejects. 
Configs it accepts, configs on hosts with no engine, and configs where the 
check could not run all take exactly the path they took before.
   - A rejected config now costs up to the existing 3 repair rounds instead of 
returning immediately. That budget is unchanged; it is the same loop that 
already handled validator failures.
   
   ### Docs
   
   No documentation change: `docs/en/ai-cli/design.md` and 
`docs/zh/ai-cli/design.md` already describe this contract, and the change 
brings the code into line with the text rather than altering it.
   
   ### Check list
   
   * [x] Code changed are covered with tests, or it does not need tests for 
reason
   * [x] If any new Jar binary package adding in your PR, please add License 
Notice according [New License 
Guide](https://github.com/apache/seatunnel/blob/dev/docs/en/contribution/new-license.md)
 — no new dependency
   * [x] If necessary, please update the documentation to describe the new 
feature — already documented
   * [x] If you are contributing the connector code, please check that the 
following files are updated — not a connector change
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)
   


-- 
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]

Reply via email to