From 1df3edaeea983b7851b07de3b01f2e080dda1fe8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E9=B9=8F?= Date: Thu, 18 Jun 2026 16:44:25 +0800 Subject: [PATCH] Document business effect amount prompt fix --- ...usiness-effect-amount-prompt-fix-design.md | 50 +++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 RuoYi-Vue/docs/superpowers/specs/2026-06-18-business-effect-amount-prompt-fix-design.md diff --git a/RuoYi-Vue/docs/superpowers/specs/2026-06-18-business-effect-amount-prompt-fix-design.md b/RuoYi-Vue/docs/superpowers/specs/2026-06-18-business-effect-amount-prompt-fix-design.md new file mode 100644 index 0000000..ec7128b --- /dev/null +++ b/RuoYi-Vue/docs/superpowers/specs/2026-06-18-business-effect-amount-prompt-fix-design.md @@ -0,0 +1,50 @@ +# Business Effect Amount Prompt Fix Design + +## Problem + +Business blueprint generation can fail with `Business effect amount is invalid`. +The validator correctly limits `INCREASE_NUMBER` and `DECREASE_NUMBER` amounts to +numeric literals or `${param.field}` placeholders, but neither the initial AI +prompt nor the correction prompt states that contract explicitly. + +The dynamic prompt example also contains no numeric effect, so the model may +return an empty amount or an arithmetic expression such as `stock - 1`. A single +correction attempt receives the same incomplete guidance and can fail again. + +## Scope + +Keep the existing safe DSL and validator unchanged. Add one shared prompt +constraint that is included in both initial generation and correction prompts: + +- `INCREASE_NUMBER` and `DECREASE_NUMBER` require `targetTable`, `targetField`, + `conditionFields`, and a non-empty `amount`. +- `amount`, `minValue`, and `NUMBER_GTE.compareValue` may only be numeric + literals or `${param.saved_column}` placeholders. +- Arithmetic expressions such as `stock - 1`, SQL fragments, units, and + descriptive text are forbidden. +- `DECREASE_NUMBER.minValue` may be omitted; the generated runtime already + defaults it to zero. + +Do not infer or default a missing amount because that could silently change +business behavior. + +## Implementation + +Extract the numeric-expression guidance into a small prompt helper in +`AiGenerateServiceImpl`. Call it from both `buildBusinessBlueprintPrompt` and +`buildBusinessBlueprintCorrectionPrompt`. + +No DTO, persistence, template, or validator changes are required. + +## Testing + +Add regression assertions proving: + +1. The initial business-blueprint prompt describes the allowed numeric forms + and rejects arithmetic expressions. +2. A correction prompt produced after an invalid amount contains the same + numeric constraint and the validation error. +3. Existing valid numeric effects still parse and persist. + +Run the targeted `AiGenerateServiceImplTest` suite, followed by the generator +module tests if the targeted suite passes.