feat(joinir): Phase 45 - JoinIR mode unification
Unified JoinIR routing logic through centralized JoinIrMode enum: Key changes: - Added JoinIrMode enum (StructuredOnly / NormalizedDev / NormalizedCanonical) - Added current_joinir_mode() for centralized mode determination - Refactored normalized_dev_enabled() as thin wrapper over mode enum - Updated bridge.rs: mode-based routing with canonical P2-Core special handling - Updated runner.rs: mode pattern matching for dev roundtrip path Files modified: - joinir_dev.rs: JoinIrMode enum + current_joinir_mode() (+49 lines) - bridge.rs: Replaced boolean checks with mode pattern matching (+29 lines) - runner.rs: Mode-based routing logic (+9 lines) - CURRENT_TASK.md: Phase 45 implementation summary Documentation: - phase45-norm-mode-design.md: Complete design spec and implementation guide Behavior preservation: - Canonical P2-Core shapes: always Normalized→MIR(direct) (mode-independent) - NormalizedDev mode: Structured→Normalized→MIR for supported shapes - StructuredOnly mode: Structured→MIR direct (default) Tests: 937/937 PASS (no regression, pure refactor) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
49
src/config/env/joinir_dev.rs
vendored
49
src/config/env/joinir_dev.rs
vendored
@ -1,8 +1,26 @@
|
||||
//! JoinIR development / experimental flags (SSOT).
|
||||
//! Phase 72-C: Consolidate all NYASH_JOINIR_* dev flags through centralized helpers.
|
||||
//! Phase 45: JoinIR mode unification (StructuredOnly / NormalizedDev / NormalizedCanonical)
|
||||
|
||||
use crate::config::env::env_bool;
|
||||
|
||||
/// Phase 45: JoinIR execution mode enum
|
||||
///
|
||||
/// Centralizes all JoinIR routing decisions (Structured vs Normalized paths).
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
pub enum JoinIrMode {
|
||||
/// Default mode: Structured→MIR direct (no Normalized layer)
|
||||
StructuredOnly,
|
||||
|
||||
/// Development mode: Structured→Normalized→MIR(direct) for supported shapes
|
||||
/// Requires `--features normalized_dev` + env var
|
||||
NormalizedDev,
|
||||
|
||||
/// Future mode: All canonical shapes use Normalized→MIR(direct)
|
||||
/// Currently unused, reserved for Phase 46+ canonical migration
|
||||
NormalizedCanonical,
|
||||
}
|
||||
|
||||
/// NYASH_JOINIR_LOWER_GENERIC=1 - Enable generic lowering path for JoinIR
|
||||
/// (CRITICAL: 15 occurrences in codebase)
|
||||
pub fn lower_generic_enabled() -> bool {
|
||||
@ -105,16 +123,37 @@ pub fn joinir_normalized_dev_run_enabled() -> bool {
|
||||
env_bool("NYASH_JOINIR_NORMALIZED_DEV_RUN")
|
||||
}
|
||||
|
||||
/// Phase 45: Get current JoinIR execution mode
|
||||
///
|
||||
/// Determines routing based on feature flags and environment variables:
|
||||
/// - `--features normalized_dev` + `NYASH_JOINIR_NORMALIZED_DEV_RUN=1` → NormalizedDev
|
||||
/// - Otherwise → StructuredOnly
|
||||
///
|
||||
/// Note: NormalizedCanonical is reserved for future canonical migration (Phase 46+)
|
||||
pub fn current_joinir_mode() -> JoinIrMode {
|
||||
#[cfg(feature = "normalized_dev")]
|
||||
{
|
||||
if joinir_normalized_dev_run_enabled() {
|
||||
JoinIrMode::NormalizedDev
|
||||
} else {
|
||||
JoinIrMode::StructuredOnly
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "normalized_dev"))]
|
||||
{
|
||||
JoinIrMode::StructuredOnly
|
||||
}
|
||||
}
|
||||
|
||||
/// Unified switch for Normalized dev experiments (feature + env).
|
||||
///
|
||||
/// - Requires `--features normalized_dev`
|
||||
/// - Requires `NYASH_JOINIR_NORMALIZED_DEV_RUN=1`
|
||||
///
|
||||
/// Phase 45: Now implemented as a thin wrapper over current_joinir_mode()
|
||||
pub fn normalized_dev_enabled() -> bool {
|
||||
if cfg!(feature = "normalized_dev") {
|
||||
joinir_normalized_dev_run_enabled()
|
||||
} else {
|
||||
false
|
||||
}
|
||||
matches!(current_joinir_mode(), JoinIrMode::NormalizedDev)
|
||||
}
|
||||
|
||||
/// JOINIR_TEST_DEBUG=1 (or NYASH_JOINIR_TEST_DEBUG=1) - Verbose logging for normalized dev tests
|
||||
|
||||
Reference in New Issue
Block a user