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

@ -266,10 +266,11 @@ impl<'a> ScopeManager for Pattern2ScopeManager<'a> {
/// promoters populate promoted_bindings map and all call sites provide BindingId.
#[cfg(feature = "normalized_dev")]
fn lookup_with_binding(&self, binding_id: Option<BindingId>, name: &str) -> Option<ValueId> {
use crate::config::env::is_joinir_debug;
if let Some(bid) = binding_id {
// Step 1: Try direct BindingId lookup in ConditionEnv (Phase 75)
if let Some(value_id) = self.condition_env.resolve_var_with_binding(Some(bid), name) {
if std::env::var("NYASH_JOINIR_DEBUG").is_ok() {
if is_joinir_debug() {
eprintln!(
"[phase76/direct] BindingId({}) -> ValueId({}) for '{}'",
bid.0, value_id.0, name
@ -282,7 +283,7 @@ impl<'a> ScopeManager for Pattern2ScopeManager<'a> {
if let Some(promoted_bid) = self.carrier_info.resolve_promoted_with_binding(bid) {
// Promoted BindingId found, lookup in ConditionEnv
if let Some(value_id) = self.condition_env.resolve_var_with_binding(Some(promoted_bid), name) {
if std::env::var("NYASH_JOINIR_DEBUG").is_ok() {
if is_joinir_debug() {
eprintln!(
"[phase76/promoted] BindingId({}) promoted to BindingId({}) -> ValueId({}) for '{}'",
bid.0, promoted_bid.0, value_id.0, name
@ -300,7 +301,7 @@ impl<'a> ScopeManager for Pattern2ScopeManager<'a> {
bid.0, name
);
#[cfg(not(feature = "normalized_dev"))]
if std::env::var("NYASH_JOINIR_DEBUG").is_ok() {
if is_joinir_debug() {
eprintln!(
"[phase76/fallback] BindingId({}) miss, falling back to name '{}' lookup",
bid.0, name