# Business Blueprint Schema Repair Implementation Plan > **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking. **Goal:** Prevent fixed prompt examples from generating invalid target-table condition fields and allow one schema-guided correction attempt. **Architecture:** `AiGenerateServiceImpl` will build its example from the saved database schema and route both initial and corrected AI responses through one parse-normalize-validate helper. Strict validation remains the authority; correction is bounded to one extra model call. **Tech Stack:** Java 8, Spring Boot, Fastjson, Mockito, JUnit 4, Maven. --- ### Task 1: Add prompt and correction regression tests **Files:** - Modify: `ruoyi-generator/src/test/java/com/ruoyi/generator/service/front/AiGenerateServiceImplTest.java` - [x] Add a valid response fixture whose rule targets `book_info` with `conditionFields: ["id"]`. - [x] Add a test using `mockSavedTablesWithGenericBookPrimaryKey()` that captures the initial prompt and asserts the JSON example contains `"conditionFields":["id"]` and does not contain a `book_info` rule conditioned by `book_id`. - [x] Add a test returning the invalid `book_id` response first and the valid `id` response second; assert two calls, a correction prompt containing the original validation error, and persisted `id`. - [x] Add a test returning invalid responses twice; assert the strict error is propagated and the AI client is called exactly twice. - [x] Run: ```powershell mvn -pl ruoyi-generator -Dtest=AiGenerateServiceImplTest test ``` Expected: the new tests fail because the prompt is fixed and there is no correction call. ### Task 2: Generate a schema-valid example **Files:** - Modify: `ruoyi-generator/src/main/java/com/ruoyi/generator/service/front/AiGenerateServiceImpl.java` - [x] Add a helper that selects the first saved table with columns. - [x] Add a helper that selects that table's primary key, falling back to its first column. - [x] Serialize a minimal action example using that table and field: ```json {"businessActions":[{"code":"example_workflow","name":"示例流程","ownerTable":"