Phase 33 NORM canon test: enforce normalized dev route for P1/P2/JP mini

This commit is contained in:
nyash-codex
2025-12-11 20:54:33 +09:00
parent 59a985b7fa
commit af6f95cd4b
170 changed files with 4423 additions and 1897 deletions

View File

@ -236,15 +236,17 @@ impl CaseALoweringShape {
// Phase 170-C-2b: Use UpdateSummary if available
if let Some(ref summary) = features.update_summary {
// Single carrier with CounterLike update → StringExamination
if summary.carriers.len() == 1
&& summary.carriers[0].kind == UpdateKind::CounterLike
{
if summary.carriers.len() == 1 && summary.carriers[0].kind == UpdateKind::CounterLike {
return CaseALoweringShape::StringExamination;
}
// Any AccumulationLike carrier → ArrayAccumulation (for single carrier)
// or IterationWithAccumulation (for multiple carriers)
if summary.carriers.iter().any(|c| c.kind == UpdateKind::AccumulationLike) {
if summary
.carriers
.iter()
.any(|c| c.kind == UpdateKind::AccumulationLike)
{
if carrier_count == 1 {
return CaseALoweringShape::ArrayAccumulation;
} else {
@ -299,12 +301,14 @@ impl CaseALoweringShape {
// Note: carriers is BTreeSet<String>, so each item is already a String
let carrier_names: Vec<String> = scope.carriers.iter().cloned().collect();
let update_summary =
crate::mir::join_ir::lowering::loop_update_summary::analyze_loop_updates_by_name(&carrier_names);
crate::mir::join_ir::lowering::loop_update_summary::analyze_loop_updates_by_name(
&carrier_names,
);
// Create stub features (Phase 170-B will use real LoopFeatures)
let stub_features = crate::mir::loop_pattern_detection::LoopFeatures {
has_break: false, // Unknown from LoopScopeShape alone
has_continue: false, // Unknown from LoopScopeShape alone
has_break: false, // Unknown from LoopScopeShape alone
has_continue: false, // Unknown from LoopScopeShape alone
has_if: false,
has_if_else_phi: false,
carrier_count,
@ -319,7 +323,10 @@ impl CaseALoweringShape {
/// Is this a recognized lowering shape?
#[allow(dead_code)]
pub fn is_recognized(&self) -> bool {
!matches!(self, CaseALoweringShape::NotCaseA | CaseALoweringShape::Generic)
!matches!(
self,
CaseALoweringShape::NotCaseA | CaseALoweringShape::Generic
)
}
/// Get human-readable name for tracing/debugging
@ -340,9 +347,18 @@ mod tests {
#[test]
fn test_shape_display() {
assert_eq!(CaseALoweringShape::StringExamination.name(), "StringExamination");
assert_eq!(CaseALoweringShape::ArrayAccumulation.name(), "ArrayAccumulation");
assert_eq!(CaseALoweringShape::IterationWithAccumulation.name(), "IterationWithAccumulation");
assert_eq!(
CaseALoweringShape::StringExamination.name(),
"StringExamination"
);
assert_eq!(
CaseALoweringShape::ArrayAccumulation.name(),
"ArrayAccumulation"
);
assert_eq!(
CaseALoweringShape::IterationWithAccumulation.name(),
"IterationWithAccumulation"
);
assert_eq!(CaseALoweringShape::Generic.name(), "Generic");
assert_eq!(CaseALoweringShape::NotCaseA.name(), "NotCaseA");
}