feat(control_tree): add StepTreeContract and signature (dev-only)

This commit is contained in:
nyash-codex
2025-12-18 00:57:58 +09:00
parent 9bcda215f8
commit 14730c227f
4 changed files with 445 additions and 15 deletions

View File

@ -41,6 +41,7 @@ pub(in crate::mir::builder) fn choose_pattern_kind(
// Phase 193: Use AST Feature Extractor Box for break/continue detection
let has_continue = ast_features::detect_continue_in_body(body);
let has_break = ast_features::detect_break_in_body(body);
let has_return = ast_features::detect_return_in_body(body);
// Phase 110: StepTree parity check (structure-only SSOT).
//
@ -56,10 +57,18 @@ pub(in crate::mir::builder) fn choose_pattern_kind(
};
let tree = StepTreeBuilderBox::build_from_ast(&loop_ast);
if tree.features.has_break != has_break || tree.features.has_continue != has_continue {
if tree.features.has_break != has_break
|| tree.features.has_continue != has_continue
|| tree.features.has_return != has_return
{
let msg = format!(
"[choose_pattern_kind/STEPTREE_PARITY] step_tree(break={}, cont={}) != extractor(break={}, cont={})",
tree.features.has_break, tree.features.has_continue, has_break, has_continue
"[choose_pattern_kind/STEPTREE_PARITY] step_tree(break={}, cont={}, ret={}) != extractor(break={}, cont={}, ret={})",
tree.features.has_break,
tree.features.has_continue,
tree.features.has_return,
has_break,
has_continue,
has_return
);
if crate::config::env::joinir_dev::strict_enabled() {