refactor(joinir): Phase 82-83 - Debug flag SSOT + Fallback verification

Phase 82: Centralized JoinIR debug flag reading
- Added is_joinir_debug() SSOT function in joinir_flags.rs
- Replaced 16 direct env::var() calls across 8 files
- Updated docs to recommend HAKO_JOINIR_DEBUG (NYASH_ deprecated)
- Backward compat: Both env vars work

Phase 83: Verified promoted carrier fallback behavior
- Confirmed NO fallback to name-based lookup for DigitPos/Trim
- Documented fallback expectations in Phase 80/81 docs
- Added verification commands and expected output

Changes:
- src/config/env/joinir_flags.rs: +187 lines (new SSOT module)
- 8 files: env var reads → is_joinir_debug() calls
- 3 docs: HAKO_JOINIR_DEBUG examples + fallback sections
- 1 summary doc: phase82-83-debug-flag-ssot-summary.md

Tests: 970/970 lib PASS, 58/58 normalized_dev PASS
Impact: Dev-only (zero production changes)
This commit is contained in:
nyash-codex
2025-12-13 19:01:14 +09:00
parent 3ff032ead5
commit 9e32807a96
12 changed files with 589 additions and 22 deletions

View File

@ -173,7 +173,8 @@ impl LoopBodyCarrierPromoter {
};
}
if std::env::var("NYASH_JOINIR_DEBUG").is_ok() || std::env::var("JOINIR_TEST_DEBUG").is_ok() {
use crate::config::env::is_joinir_debug;
if is_joinir_debug() || std::env::var("JOINIR_TEST_DEBUG").is_ok() {
eprintln!(
"[promoter/pattern5] Phase 171-C: Found {} LoopBodyLocal variables: {:?}",
body_locals.len(),
@ -196,7 +197,7 @@ impl LoopBodyCarrierPromoter {
// Phase 79: Use TrimDetector for pure detection logic
if let Some(detection) = TrimDetector::detect(break_cond, request.loop_body, var_name)
{
if std::env::var("NYASH_JOINIR_DEBUG").is_ok() || std::env::var("JOINIR_TEST_DEBUG").is_ok() {
if is_joinir_debug() || std::env::var("JOINIR_TEST_DEBUG").is_ok() {
eprintln!(
"[promoter/pattern5] Trim pattern detected! var='{}', literals={:?}",
detection.match_var, detection.comparison_literals
@ -231,7 +232,8 @@ impl LoopBodyCarrierPromoter {
/// Phase 78: Log promotion errors with clear messages (for Trim pattern, gated)
#[cfg(feature = "normalized_dev")]
fn log_trim_promotion_error(error: &BindingRecordError) {
if std::env::var("NYASH_JOINIR_DEBUG").is_ok() || std::env::var("JOINIR_TEST_DEBUG").is_ok() {
use crate::config::env::is_joinir_debug;
if is_joinir_debug() || std::env::var("JOINIR_TEST_DEBUG").is_ok() {
match error {
BindingRecordError::OriginalNotFound(name) => {
eprintln!(

View File

@ -129,7 +129,8 @@ impl DigitPosPromoter {
};
}
if std::env::var("NYASH_JOINIR_DEBUG").is_ok() || std::env::var("JOINIR_TEST_DEBUG").is_ok() {
use crate::config::env::is_joinir_debug;
if is_joinir_debug() || std::env::var("JOINIR_TEST_DEBUG").is_ok() {
eprintln!(
"[digitpos_promoter] Phase 224: Found {} LoopBodyLocal variables: {:?}",
body_locals.len(),
@ -162,7 +163,7 @@ impl DigitPosPromoter {
}
let detection = detection.unwrap();
if std::env::var("NYASH_JOINIR_DEBUG").is_ok() || std::env::var("JOINIR_TEST_DEBUG").is_ok() {
if is_joinir_debug() || std::env::var("JOINIR_TEST_DEBUG").is_ok() {
eprintln!(
"[digitpos_promoter] Pattern detected: {}{} (bool) + {} (int)",
detection.var_name, detection.bool_carrier_name, detection.int_carrier_name
@ -222,7 +223,7 @@ impl DigitPosPromoter {
log_promotion_error(&e);
}
if std::env::var("NYASH_JOINIR_DEBUG").is_ok() || std::env::var("JOINIR_TEST_DEBUG").is_ok() {
if is_joinir_debug() || std::env::var("JOINIR_TEST_DEBUG").is_ok() {
eprintln!(
"[digitpos_promoter] Phase 247-EX: A-4 DigitPos pattern promoted: {}{} (bool) + {} (i64)",
detection.var_name, detection.bool_carrier_name, detection.int_carrier_name
@ -252,7 +253,8 @@ impl DigitPosPromoter {
/// Phase 78: Log promotion errors with clear messages (gated)
#[cfg(feature = "normalized_dev")]
fn log_promotion_error(error: &BindingRecordError) {
if std::env::var("NYASH_JOINIR_DEBUG").is_ok() || std::env::var("JOINIR_TEST_DEBUG").is_ok() {
use crate::config::env::is_joinir_debug;
if is_joinir_debug() || std::env::var("JOINIR_TEST_DEBUG").is_ok() {
match error {
BindingRecordError::OriginalNotFound(name) => {
eprintln!(