Files
2026-07-17 17:45:56 +08:00

70 lines
2.8 KiB
Markdown

# RuleTemplateGenerator
Converts teaching material into an executable rule package.
This tool is the future LLM-facing side of the diagnostic system. For now, the agent authors the first built-in rule package directly; later an LLM adapter should emit the same JSON contract.
## Responsibility
`RuleTemplateGenerator` handles only teaching material:
- input: teaching image and optional teaching text
- output: semantic rule templates plus image-side 2D structure templates
- it does not open SolidWorks models
- it does not decide whether a product model is correct
## Output Layers
The generated package has two required layers:
```text
teaching image/text
-> semantic rule template
-> image 2D structure template
```
The semantic rule template says when a rule applies, what problem is reported, and which pass evidence can prove the design is acceptable.
The image 2D structure template preserves drawable structural relations from the figure, such as contact, outside connectivity, gaps, ports, blocked paths, and anchors such as `m/h/t`. Hatch lines, table borders, line thickness, and printed scale are ignored.
## LLM Contract
Later, the LLM must output the same package structure. It is responsible for:
- extracting the rule object and trigger condition
- understanding which figure is problem evidence and which figures are pass evidence
- extracting visual anchors such as `m/h/t`
- producing image-side 2D structure templates
- listing the model evidence that the program must verify
The LLM must not decide whether a SolidWorks model has a fault. That belongs to `ModelDiagnosticVerifier`.
This tool is generic. The sleeve-removal rule is only the first sample; future rules such as bearing mounting, axial part limiting, keyway orientation, gear-on-shaft checks, and cover fastening should use the same package structure.
## Usage
Generate from a teaching image:
```powershell
dotnet run --project tools\model-diagnostics\RuleTemplateGenerator\RuleTemplateGenerator.csproj -c Release -- generate --image "D:\path\teaching.png" --out runtime\rule_templates\rule.json
```
Generate from a teaching image plus extracted text:
```powershell
dotnet run --project tools\model-diagnostics\RuleTemplateGenerator\RuleTemplateGenerator.csproj -c Release -- generate --image "D:\path\teaching.png" --text "D:\path\teaching.txt" --out runtime\rule_templates\rule.json
```
Create the current built-in sleeve-removal sample:
```powershell
dotnet run --project tools\model-diagnostics\RuleTemplateGenerator\RuleTemplateGenerator.csproj -c Release -- sample-sleeve runtime\rule_templates\tight_fit_sleeve_requires_disassembly_access.json
```
Validate a generated package:
```powershell
dotnet run --project tools\model-diagnostics\RuleTemplateGenerator\RuleTemplateGenerator.csproj -c Release -- validate runtime\rule_templates\tight_fit_sleeve_requires_disassembly_access.json
```