Phase 21.4 Complete: FileBox SSOT + Analyzer Stabilization (7 Tasks)
✅ Task 1: Fallback Guarantee (create_box failure → ring1/core-ro auto fallback) - Three-tier fallback system: plugin → builtin → core-ro - Mode control: auto/plugin-only/core-ro - New: src/box_factory/builtin_impls/file_box.rs - New: tools/test_filebox_fallback_smoke.sh ✅ Task 2: Provider Registration SSOT (static/dynamic/core-ro unified) - ProviderFactory trait with priority-based selection - Global registry PROVIDER_FACTORIES implementation - Priority: dynamic(100) > builtin(10) > core-ro(0) - New: src/boxes/file/builtin_factory.rs - New: tools/smoke_provider_modes.sh ✅ Task 3: FileBox Publication Unification - Verified: basic/file_box.rs already minimized (11 lines) - Perfect re-export pattern maintained ✅ Task 4: ENV Unification (FILEBOX_MODE/DISABLE_PLUGINS priority) - Removed auto-setting of NYASH_USE_PLUGIN_BUILTINS - Removed auto-setting of NYASH_PLUGIN_OVERRIDE_TYPES - Added deprecation warnings with migration guide - ENV hierarchy: DISABLE_PLUGINS > BOX_FACTORY_POLICY > FILEBOX_MODE ✅ Task 5: Error Log Visibility (Analyzer rule execution errors to stderr) - Added [rule/exec] logging before IR-based rule execution - Format: [rule/exec] HC012 (dead_static_box) <filepath> - VM errors now traceable via stderr output ✅ Task 6: Unnecessary Using Removal (14 rules Str alias cleanup) - Removed unused `using ... as Str` from 14 rule files - All rules use local _itoa() helper instead - 14 lines of dead code eliminated ✅ Task 7: HC017 Skip & TODO Documentation (UTF-8 support required) - Enhanced run_tests.sh with clear skip message - Added "Known Limitations" section to README.md - Technical requirements documented (3 implementation options) - Re-enable timeline: Phase 22 (Unicode Support Phase) 📊 Test Results: - Analyzer: 10 tests PASS, 1 skipped (HC017) - FileBox fallback: All 3 modes PASS - Provider modes: All 4 modes PASS - Build: Success (0 errors, 0 warnings) 🎯 Key Achievements: - 28 files modified/created - Three-Tier Fallback System (stability) - SSOT Provider Registry (extensibility) - ENV unification (operational clarity) - Error visibility (debugging efficiency) - Code cleanup (maintainability) - Comprehensive documentation (Phase 22 ready) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@ -7,35 +7,42 @@ use super::*;
|
||||
impl NyashRunner {
|
||||
/// Initialize global runtime registry and load configured plugins.
|
||||
///
|
||||
/// Behavior (no-op changes to defaults):
|
||||
/// Behavior (Phase 21.4: Unified ENV Policy):
|
||||
/// - Always initializes the unified type/box registry.
|
||||
/// - Loads native BID plugins unless `NYASH_DISABLE_PLUGINS=1`.
|
||||
/// - Ensures built‑ins override list includes ArrayBox/MapBox/FileBox/TOMLBox
|
||||
/// by merging `NYASH_PLUGIN_OVERRIDE_TYPES` with required entries.
|
||||
/// - When `--load-ny-plugins` or `NYASH_LOAD_NY_PLUGINS=1` is set, best‑effort
|
||||
/// loads Nyash scripts listed under `nyash.toml`'s `ny_plugins`.
|
||||
///
|
||||
/// Side effects:
|
||||
/// - Sets `NYASH_USE_PLUGIN_BUILTINS=1` if unset, to allow interpreter side creation.
|
||||
/// - Updates `NYASH_PLUGIN_OVERRIDE_TYPES` env var (merged values).
|
||||
/// ENV Policy:
|
||||
/// - NYASH_DISABLE_PLUGINS=1: Skip all plugin initialization
|
||||
/// - NYASH_BOX_FACTORY_POLICY: Control factory priority (builtin_first|strict_plugin_first|compat_plugin_first)
|
||||
/// - NYASH_FILEBOX_MODE: FileBox provider selection (auto|core-ro|plugin-only)
|
||||
///
|
||||
/// Deprecated ENV (removed auto-setting):
|
||||
/// - NYASH_USE_PLUGIN_BUILTINS: No longer auto-set (use policy instead)
|
||||
/// - NYASH_PLUGIN_OVERRIDE_TYPES: No longer auto-set (use policy instead)
|
||||
pub(crate) fn init_runtime_and_plugins(&self, groups: &crate::cli::CliGroups) {
|
||||
// Unified registry
|
||||
// Check if plugins are disabled
|
||||
let plugins_disabled = std::env::var("NYASH_DISABLE_PLUGINS").ok().as_deref() == Some("1");
|
||||
|
||||
// Unified registry (always initialize)
|
||||
runtime::init_global_unified_registry();
|
||||
// Plugins (guarded)
|
||||
if std::env::var("NYASH_DISABLE_PLUGINS").ok().as_deref() != Some("1") {
|
||||
|
||||
// Plugins (guarded by NYASH_DISABLE_PLUGINS)
|
||||
if !plugins_disabled {
|
||||
runner_plugin_init::init_bid_plugins();
|
||||
crate::runner::box_index::refresh_box_index();
|
||||
} else {
|
||||
eprintln!("[plugins] Skipping plugin initialization (NYASH_DISABLE_PLUGINS=1)");
|
||||
}
|
||||
// Allow interpreter to create plugin-backed boxes via unified registry
|
||||
if std::env::var("NYASH_USE_PLUGIN_BUILTINS").ok().is_none() {
|
||||
std::env::set_var("NYASH_USE_PLUGIN_BUILTINS", "1");
|
||||
|
||||
// Deprecation warnings for old ENV variables
|
||||
if std::env::var("NYASH_USE_PLUGIN_BUILTINS").is_ok() {
|
||||
eprintln!("[warn] NYASH_USE_PLUGIN_BUILTINS is deprecated. Use NYASH_BOX_FACTORY_POLICY instead.");
|
||||
}
|
||||
if std::env::var("NYASH_PLUGIN_OVERRIDE_TYPES").is_ok() {
|
||||
eprintln!("[warn] NYASH_PLUGIN_OVERRIDE_TYPES is deprecated. Use NYASH_BOX_FACTORY_POLICY instead.");
|
||||
}
|
||||
// Merge override types env (ensure FileBox/TOMLBox present)
|
||||
let mut override_types: Vec<String> = if let Ok(list) = std::env::var("NYASH_PLUGIN_OVERRIDE_TYPES") {
|
||||
list.split(',').map(|s| s.trim().to_string()).filter(|s| !s.is_empty()).collect()
|
||||
} else { vec!["ArrayBox".into(), "MapBox".into()] };
|
||||
for t in ["FileBox", "TOMLBox"] { if !override_types.iter().any(|x| x == t) { override_types.push(t.into()); } }
|
||||
std::env::set_var("NYASH_PLUGIN_OVERRIDE_TYPES", override_types.join(","));
|
||||
|
||||
// Optional Ny script plugins loader (best-effort)
|
||||
if groups.load_ny_plugins || std::env::var("NYASH_LOAD_NY_PLUGINS").ok().as_deref() == Some("1") {
|
||||
|
||||
Reference in New Issue
Block a user