fix(joinir): wire balanced depth-scan policy through Pattern2

This commit is contained in:
nyash-codex
2025-12-17 22:47:36 +09:00
parent 9ec2e28b6a
commit d8ce9fdb99
4 changed files with 121 additions and 29 deletions

View File

@ -24,11 +24,18 @@ pub(in crate::mir::builder) fn choose_pattern_kind(
// Phase 107: Route balanced depth-scan (return-in-loop) to Pattern2 via policy.
//
// This keeps Pattern routing structural: no by-name dispatch, no silent fallback.
if matches!(
classify_balanced_depth_scan_array_end(condition, body),
PolicyDecision::Use(_)
) {
return loop_pattern_detection::LoopPatternKind::Pattern2Break;
match classify_balanced_depth_scan_array_end(condition, body) {
PolicyDecision::Use(_) => {
return loop_pattern_detection::LoopPatternKind::Pattern2Break;
}
PolicyDecision::Reject(_reason) => {
// In strict mode, treat "close-but-unsupported" as a fail-fast
// Pattern2 route so the policy can surface the precise contract violation.
if crate::config::env::joinir_dev::strict_enabled() {
return loop_pattern_detection::LoopPatternKind::Pattern2Break;
}
}
PolicyDecision::None => {}
}
// Phase 193: Use AST Feature Extractor Box for break/continue detection