feat(joinir/dev): build Normalized if-only module with structure verification (no behavior change)
Phase 122 P2-P3: Dev-only wiring + structure verification - Wire Phase 122 emission into existing Phase 121 dev path - Add verify_normalized_structure() for module validation - Check: phase, function count, entry point, env args count - Strict mode: fail-fast on structure mismatch - No behavior change to existing execution path
This commit is contained in:
@ -137,6 +137,62 @@ pub fn check_full_parity(
|
||||
ShadowParityResult::ok()
|
||||
}
|
||||
|
||||
/// Phase 122: Verify Normalized JoinModule structure
|
||||
///
|
||||
/// ## Contract
|
||||
///
|
||||
/// - Checks function count, continuation count, tail-call form, env args
|
||||
/// - Does NOT check actual execution (RC comparison is optional)
|
||||
/// - Returns mismatch with hint if structure is invalid
|
||||
pub fn verify_normalized_structure(
|
||||
module: &crate::mir::join_ir::JoinModule,
|
||||
expected_env_fields: usize,
|
||||
) -> ShadowParityResult {
|
||||
use crate::mir::join_ir::JoinIrPhase;
|
||||
|
||||
// Check phase
|
||||
if !module.is_normalized() {
|
||||
let hint = format!(
|
||||
"module phase is not Normalized: {:?}",
|
||||
module.phase
|
||||
);
|
||||
return ShadowParityResult::mismatch(MismatchKind::UnsupportedKind, hint);
|
||||
}
|
||||
|
||||
// Check function count (Phase 122 minimal: 1 main function)
|
||||
if module.functions.is_empty() {
|
||||
let hint = "no functions in module".to_string();
|
||||
return ShadowParityResult::mismatch(MismatchKind::UnsupportedKind, hint);
|
||||
}
|
||||
|
||||
// Check entry point
|
||||
if module.entry.is_none() {
|
||||
let hint = "no entry point in module".to_string();
|
||||
return ShadowParityResult::mismatch(MismatchKind::UnsupportedKind, hint);
|
||||
}
|
||||
|
||||
// Check main function exists
|
||||
let entry_id = module.entry.unwrap();
|
||||
let main_func = module.functions.get(&entry_id);
|
||||
if main_func.is_none() {
|
||||
let hint = format!("entry function {:?} not found", entry_id);
|
||||
return ShadowParityResult::mismatch(MismatchKind::UnsupportedKind, hint);
|
||||
}
|
||||
|
||||
// Check env args count (Phase 122: writes only)
|
||||
let main_func = main_func.unwrap();
|
||||
if main_func.params.len() != expected_env_fields {
|
||||
let hint = format!(
|
||||
"env args mismatch: expected {}, got {}",
|
||||
expected_env_fields,
|
||||
main_func.params.len()
|
||||
);
|
||||
return ShadowParityResult::mismatch(MismatchKind::UnsupportedKind, hint);
|
||||
}
|
||||
|
||||
ShadowParityResult::ok()
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
Reference in New Issue
Block a user