diff --git a/skills/ir_generation_skill/step1_semantic_index.py b/skills/ir_generation_skill/step1_semantic_index.py index bf38da6..c8a73cc 100644 --- a/skills/ir_generation_skill/step1_semantic_index.py +++ b/skills/ir_generation_skill/step1_semantic_index.py @@ -880,9 +880,9 @@ def run_ensemble_semantic_index(doc: dict) -> dict: if v: print(f" {k}: {len(v)} 个问题") - # Feedback retry: re-run with coverage feedback (up to 2 retries, quality-gated) + # Feedback retry: re-run with coverage feedback (up to 3 retries, quality-gated) retry_count = 0 - while retry_count < 2: + while retry_count < 3: feedback = _build_coverage_feedback(gaps) if not feedback: break @@ -906,13 +906,16 @@ def run_ensemble_semantic_index(doc: dict) -> dict: if src.get("section"): retry_sections.add(src["section"]) print(f" 重试新增 sections: {sorted(retry_sections)}", flush=True) - # Quality gate: only include retry if it improves coverage + # Quality gate: include retry if it adds new sections or doesn't regress coverage trial_indices = semantic_indices + [retry_result] trial_merged = ensemble_merge(trial_indices) trial_passed, trial_gaps = _quick_validate(trial_merged, doc, all_paths) trial_warnings = len(trial_gaps.get("coverage_warnings", [])) trial_missing = len(trial_gaps.get("missing_table_rows", [])) - if trial_warnings < pre_warnings or trial_missing < pre_missing_rows: + improved = trial_warnings < pre_warnings or trial_missing < pre_missing_rows + no_regression = trial_warnings <= pre_warnings and trial_missing <= pre_missing_rows + has_new_sections = len(retry_sections) > 0 + if improved or (no_regression and has_new_sections): semantic_indices.append(retry_result) merged = trial_merged passed, gaps = trial_passed, trial_gaps