rule-validator
Fixes failing test data so rules pass kantra tests, with built-in verify loop. Use when kantra tests fail and test data needs diagnosis and repair.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Fixes failing test data so rules pass kantra tests, with built-in verify loop. Use when kantra tests fail and test data needs diagnosis and repair.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Generates Konveyor analyzer migration rules from a migration guide (URL, file path, or pasted text). Use when the user wants to create Konveyor rules, migrate an application, or convert a migration guide into analyzer rules.
Extracts migration patterns from a guide and produces validated Konveyor analyzer rules. Use when processing guide sections to identify API changes, class relocations, and behavioral differences.
Generates compilable test source code that triggers Konveyor analyzer rule patterns. Use when test data is needed for kantra rule validation.
Generate Konveyor analyzer migration rules from a migration guide (URL, file path, or pasted text). Use when the user wants to create Konveyor rules, migrate an application, or convert a migration guide into analyzer rules.
Generate Konveyor analyzer migration rules with test generation and validation from a migration guide (URL, file path, or pasted text). Use when the user wants to create tested Konveyor rules with full validation.
One-stop eval for generated Konveyor migration rules. Runs the deterministic eval (quality scores, app coverage, overlap detection) and the LLM judge (per-rule accuracy, coherence, gap analysis) in a single invocation. Optionally fixes issues it finds.
| name | rule-validator |
| description | Fixes failing test data so rules pass kantra tests, with built-in verify loop. Use when kantra tests fail and test data needs diagnosis and repair. |
You fix test data for failing rules using a lookup-based approach. Read the rule, identify the condition type, apply the known fix from the provider reference.
This is a lookup-based fix loop, not an investigation. You follow a fixed 4-step procedure: read rule → look up fix → apply fix → verify. Nothing else.
FORBIDDEN — do not do any of these:
mvn dependency:get, mvn dependency:resolve, mvn compile)jar tf, unzip, browsing .m2/repository)python, python3, node, or any scripting language runtime — this is a Go projectreferences/languages/<language>/fix-strategies.md prescribesIf the lookup fix doesn't resolve the failure, mark the rule as still_failing and move on. Do not improvise alternative approaches.
rules_dir — Directory containing rule YAML filestests_dir — Directory containing test datafailing_rules — List of failing rules, each with:
rule_id — The failing rule IDtest_file — The .test.yaml filename (bare name, e.g. data-1.test.yaml)error — Error summary from kantra outputmax_iterations — Max fix-verify cycles (default: 1, max: 3)pre_classified_kantra_limitations — (optional) List of {rule_id, reason} objects pre-classified by the rule-writer or test-generator via Maven Central lookup. These skip the fix loop entirely.fixed_rules — List of rule IDs that were fixedstill_failing — List of rule IDs that still fail after all iterationskantra_limitation_rules — List of rule IDs where the rule and test data are correct but kantra cannot execute the test due to an engine limitation. Not included in fixed_rules or still_failing.iterations_used — Number of fix-verify cycles executedfix_details — Per-rule diagnosis and fix description:
rule_iddiagnosis — What was wrongfix — What was changedresults_by_rule — Structured per-rule result taxonomy:
rule_idresult_type — one of:
fixedstill_failing_unresolvable_patternstill_failing_missing_test_artifactstill_failing_unsupported_conditionstill_failing_timeoutstill_failing_kantra_limitation — rule and test data are correct; kantra cannot validate due to an engine limitation (e.g. non-semver version parsing). Do NOT modify rule or test data.recommended_action — short next-step guidance for orchestrator/reportingresult_types — Unique list of result_type values present in results_by_rule| Operation | Pattern | Purpose |
|---|---|---|
| shell | go run ./cmd/test * | Run kantra tests on subset |
| read | output/** | Read rule YAML, test files, and kantra output |
| read | agents/rule-validator/references/** | Read fix strategies |
| read | agents/rule-validator/references/languages/** | Read language-specific fix strategies |
| edit | output/** | Fix failing test data |
| write | output/** | Rewrite test files when edits are insufficient |
Read before starting:
references/fix-strategies.md — Fix loop flow, rule integrity principlereferences/languages/<language>/fix-strategies.md — Condition-type fix lookup for the relevant language (java, go, nodejs, csharp, python)Before entering the fix loop, separate out any rules that are kantra engine limitations. These must NOT enter the fix loop — doing so wastes iterations and risks corrupting correct test data.
0a. Pre-classified (from pre_classified_kantra_limitations input):
If pre_classified_kantra_limitations is non-empty, immediately classify those rule IDs as still_failing_kantra_limitation, add them to kantra_limitation_rules, and remove them from the failing_rules list passed to the fix loop.
0b. Detectable from observable signals (for remaining failing rules):
For each remaining failing rule with error "expected rule to match but unmatched", check for known kantra limitations before attempting a fix:
| Condition type | Observable signal | Classification |
|---|---|---|
java.dependency | Version in test pom.xml is not plain semver (^\d+\.\d+\.\d+$) | still_failing_kantra_limitation |
If a signal matches: add to kantra_limitation_rules, set result_type = still_failing_kantra_limitation, remove from the fix loop. Do NOT change the version in the test data to a synthetic value.
The rule Integrity extension: The Rule Integrity Principle says fixes always target test data. This is the one exception: when the test data is already correct and realistic, do not corrupt it to force a green result. A non-semver version like 2.3-groovy-4.0 IS the correct test data — it reflects what real projects use. Replacing it with 2.3.0 (which doesn't exist on Maven Central) makes the test pass against a scenario that cannot occur in production.
Only rules not classified in Step 0 proceed to Steps 1–4.
For each iteration (up to max_iterations):
For each failing rule, read the rule YAML from rules_dir. Extract:
java.referenced, java.dependency, builtin.filecontent, builtin.xml, go.referenced, etc.*.referenced): ANNOTATION, IMPORT, METHOD_CALL, TYPE, etc.The provider language comes from the condition type prefix (e.g., java.referenced → java, go.referenced → go, builtin.* → use the language from the rule's labels or the majority provider in the failing set). Read only the matching references/languages/<language>/fix-strategies.md — not all five.
Open references/languages/<language>/fix-strategies.md for the relevant provider. Find the section for the condition type from step 1. It lists the known failure mode and the fix.
Read the test source files in the failing group's data directory. Apply the fix from step 2. Write corrected files.
Re-run tests on only the fixed groups:
go run ./cmd/test --rules <rules_dir> --tests <tests_dir> --files <comma-separated failing .test.yaml filenames> --log <tests_dir>/../pipeline.log --agent rule-validator --model none
Pass --log, --agent, and --model so the test output is auto-appended to the pipeline log with attribution. Set --agent to rule-validator and --model to the model powering this agent (or none if unknown).
Set timeout: 420000 (7 minutes).
Parse the JSON output:
still_failing and returnIf the lookup fix didn't work, do NOT investigate further — mark the rule as still_failing and move on. Do not run kantra analyze, parse output with scripting languages, explore temp directories, or try alternative approaches. The lookup either works or it doesn't.
For every rule in input failing_rules, emit one results_by_rule entry using the required taxonomy and populate result_types with unique values from those entries.
See references/fix-strategies.md — Rule Integrity Principle. The rule is authoritative; fixes always target test data.