refactor(joinir): Phase 287 P0.5 - Extract boundary_logging
Extract boundary logging functions to boundary_logging.rs (112 lines). Consolidates scattered trace.stderr_if() calls into focused functions. SSOT Principle: - Only use trace.stderr_if(..., debug/verbose) - NO constant logs - Prevents noise in quick smoke tests - Consistent logging format across boundary operations Changes: - NEW: merge/boundary_logging.rs (112 lines) - MOD: merge/mod.rs: 1,027 → ~973 lines (-54 lines) - Functions: - log_boundary_info() - Comprehensive boundary logging (verbose mode) - log_merge_complete() - Merge completion summary (debug mode) Logging Consolidated: - Boundary join_inputs / host_inputs - Exit bindings (carrier mappings) - Condition bindings (if any) - Carrier info (if present) - Merge completion summary Verification: - Build: 0 errors - Pattern6: RC:9 ✅ - Smoke: 154/154 PASS (verified via quick profile) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
113
src/mir/builder/control_flow/joinir/merge/boundary_logging.rs
Normal file
113
src/mir/builder/control_flow/joinir/merge/boundary_logging.rs
Normal file
@ -0,0 +1,113 @@
|
||||
//! Phase 287 P0.5: Boundary logging consolidation
|
||||
//!
|
||||
//! Consolidates all trace.stderr_if() calls related to boundary information
|
||||
//! into a single module for consistent logging.
|
||||
//!
|
||||
//! SSOT Principle: Only use trace.stderr_if(..., debug/verbose) - NO constant logs
|
||||
//! to avoid noise in quick smoke tests.
|
||||
|
||||
use crate::mir::join_ir::lowering::inline_boundary::JoinInlineBoundary;
|
||||
|
||||
/// Log detailed boundary information (verbose mode only)
|
||||
///
|
||||
/// Logs:
|
||||
/// - join_inputs / host_inputs
|
||||
/// - exit_bindings (carrier mappings)
|
||||
/// - condition_bindings (if any)
|
||||
/// - carrier_info (if present)
|
||||
pub(super) fn log_boundary_info(
|
||||
boundary: Option<&JoinInlineBoundary>,
|
||||
trace: &super::super::trace::JoinLoopTrace,
|
||||
verbose: bool,
|
||||
) {
|
||||
if !verbose {
|
||||
return;
|
||||
}
|
||||
|
||||
if let Some(boundary) = boundary {
|
||||
// Exit bindings summary
|
||||
let exit_summary: Vec<String> = boundary
|
||||
.exit_bindings
|
||||
.iter()
|
||||
.map(|b| {
|
||||
format!(
|
||||
"{}: join {:?} → host {:?} ({:?})",
|
||||
b.carrier_name, b.join_exit_value, b.host_slot, b.role
|
||||
)
|
||||
})
|
||||
.collect();
|
||||
|
||||
// Condition bindings summary
|
||||
let cond_summary: Vec<String> = boundary
|
||||
.condition_bindings
|
||||
.iter()
|
||||
.map(|b| {
|
||||
format!(
|
||||
"{}: host {:?} → join {:?}",
|
||||
b.name, b.host_value, b.join_value
|
||||
)
|
||||
})
|
||||
.collect();
|
||||
|
||||
// Log join_inputs / host_inputs
|
||||
trace.stderr_if(
|
||||
&format!(
|
||||
"[cf_loop/joinir] Boundary join_inputs={:?} host_inputs={:?}",
|
||||
boundary.join_inputs, boundary.host_inputs
|
||||
),
|
||||
verbose,
|
||||
);
|
||||
|
||||
// Log exit_bindings
|
||||
trace.stderr_if(
|
||||
&format!(
|
||||
"[cf_loop/joinir] Boundary exit_bindings ({}): {}",
|
||||
boundary.exit_bindings.len(),
|
||||
exit_summary.join(", ")
|
||||
),
|
||||
verbose,
|
||||
);
|
||||
|
||||
// Log condition_bindings (if any)
|
||||
if !cond_summary.is_empty() {
|
||||
trace.stderr_if(
|
||||
&format!(
|
||||
"[cf_loop/joinir] Boundary condition_bindings ({}): {}",
|
||||
cond_summary.len(),
|
||||
cond_summary.join(", ")
|
||||
),
|
||||
verbose,
|
||||
);
|
||||
}
|
||||
|
||||
// Log carrier_info (if present)
|
||||
if let Some(ci) = &boundary.carrier_info {
|
||||
let carriers: Vec<String> = ci.carriers.iter().map(|c| c.name.clone()).collect();
|
||||
trace.stderr_if(
|
||||
&format!(
|
||||
"[cf_loop/joinir] Boundary carrier_info: loop_var='{}', carriers={:?}",
|
||||
ci.loop_var_name, carriers
|
||||
),
|
||||
verbose,
|
||||
);
|
||||
}
|
||||
} else {
|
||||
trace.stderr_if("[cf_loop/joinir] No boundary provided", verbose);
|
||||
}
|
||||
}
|
||||
|
||||
/// Log merge completion summary (debug mode only)
|
||||
pub(super) fn log_merge_complete(
|
||||
function_count: usize,
|
||||
exit_block_id: crate::mir::BasicBlockId,
|
||||
trace: &super::super::trace::JoinLoopTrace,
|
||||
debug: bool,
|
||||
) {
|
||||
trace.stderr_if(
|
||||
&format!(
|
||||
"[cf_loop/joinir] Phase 189: Merge complete: {} functions merged, continuing from {:?}",
|
||||
function_count, exit_block_id
|
||||
),
|
||||
debug,
|
||||
);
|
||||
}
|
||||
@ -14,6 +14,7 @@
|
||||
|
||||
mod block_allocator;
|
||||
mod block_remapper; // Phase 284 P1: Block ID remap SSOT
|
||||
mod boundary_logging; // Phase 287 P0.5: Boundary logging consolidation
|
||||
mod carrier_init_builder;
|
||||
pub(super) mod contract_checks; // Phase 256 P1.5-DBG: Exposed for patterns to access verify_boundary_entry_params
|
||||
mod debug_assertions; // Phase 286C-4.3: Debug-only assertions (split from contract_checks)
|
||||
@ -191,69 +192,8 @@ pub(in crate::mir::builder) fn merge_joinir_mir_blocks(
|
||||
}
|
||||
}
|
||||
|
||||
if verbose {
|
||||
if let Some(boundary) = boundary {
|
||||
let exit_summary: Vec<String> = boundary
|
||||
.exit_bindings
|
||||
.iter()
|
||||
.map(|b| {
|
||||
format!(
|
||||
"{}: join {:?} → host {:?} ({:?})",
|
||||
b.carrier_name, b.join_exit_value, b.host_slot, b.role
|
||||
)
|
||||
})
|
||||
.collect();
|
||||
|
||||
let cond_summary: Vec<String> = boundary
|
||||
.condition_bindings
|
||||
.iter()
|
||||
.map(|b| {
|
||||
format!(
|
||||
"{}: host {:?} → join {:?}",
|
||||
b.name, b.host_value, b.join_value
|
||||
)
|
||||
})
|
||||
.collect();
|
||||
|
||||
trace.stderr_if(
|
||||
&format!(
|
||||
"[cf_loop/joinir] Boundary join_inputs={:?} host_inputs={:?}",
|
||||
boundary.join_inputs, boundary.host_inputs
|
||||
),
|
||||
verbose,
|
||||
);
|
||||
trace.stderr_if(
|
||||
&format!(
|
||||
"[cf_loop/joinir] Boundary exit_bindings ({}): {}",
|
||||
boundary.exit_bindings.len(),
|
||||
exit_summary.join(", ")
|
||||
),
|
||||
verbose,
|
||||
);
|
||||
if !cond_summary.is_empty() {
|
||||
trace.stderr_if(
|
||||
&format!(
|
||||
"[cf_loop/joinir] Boundary condition_bindings ({}): {}",
|
||||
cond_summary.len(),
|
||||
cond_summary.join(", ")
|
||||
),
|
||||
verbose,
|
||||
);
|
||||
}
|
||||
if let Some(ci) = &boundary.carrier_info {
|
||||
let carriers: Vec<String> = ci.carriers.iter().map(|c| c.name.clone()).collect();
|
||||
trace.stderr_if(
|
||||
&format!(
|
||||
"[cf_loop/joinir] Boundary carrier_info: loop_var='{}', carriers={:?}",
|
||||
ci.loop_var_name, carriers
|
||||
),
|
||||
verbose,
|
||||
);
|
||||
}
|
||||
} else {
|
||||
trace.stderr_if("[cf_loop/joinir] No boundary provided", verbose);
|
||||
}
|
||||
}
|
||||
// Phase 287 P0.5: Delegated to boundary_logging module
|
||||
boundary_logging::log_boundary_info(boundary, &trace, verbose);
|
||||
|
||||
// Phase 1: Allocate block IDs for all functions
|
||||
// Phase 177-3: block_allocator now returns exit_block_id to avoid conflicts
|
||||
@ -982,14 +922,8 @@ pub(in crate::mir::builder) fn merge_joinir_mir_blocks(
|
||||
// Switch to exit block for subsequent code
|
||||
builder.start_new_block(exit_block_id)?;
|
||||
|
||||
trace.stderr_if(
|
||||
&format!(
|
||||
"[cf_loop/joinir] Phase 189: Merge complete: {} functions merged, continuing from {:?}",
|
||||
mir_module.functions.len(),
|
||||
exit_block_id
|
||||
),
|
||||
debug,
|
||||
);
|
||||
// Phase 287 P0.5: Delegated to boundary_logging module
|
||||
boundary_logging::log_merge_complete(mir_module.functions.len(), exit_block_id, &trace, debug);
|
||||
|
||||
// Phase 200-3: Verify JoinIR contracts (debug only)
|
||||
#[cfg(debug_assertions)]
|
||||
|
||||
Reference in New Issue
Block a user