feat(plugin): Phase 134 P1 - Core box strict guard (SSOT in plugin_guard.rs)
This commit is contained in:
@ -5,6 +5,19 @@
|
||||
* consistent diagnostics across runner modes.
|
||||
*/
|
||||
|
||||
/// Core required providers (SSOT - Phase 134 P1)
|
||||
///
|
||||
/// These are essential for basic program execution (substring, array ops, console output).
|
||||
/// Missing any of these in strict mode will cause immediate failure.
|
||||
pub fn gather_core_required_providers() -> Vec<String> {
|
||||
vec![
|
||||
"StringBox".to_string(),
|
||||
"IntegerBox".to_string(),
|
||||
"ArrayBox".to_string(),
|
||||
"ConsoleBox".to_string(),
|
||||
]
|
||||
}
|
||||
|
||||
/// Build the list of required provider type names.
|
||||
///
|
||||
/// Priority:
|
||||
@ -57,7 +70,7 @@ fn emit_hints_for(missing: &[String]) {
|
||||
|
||||
/// Check provider availability and emit diagnostics.
|
||||
///
|
||||
/// - `strict`: exit(1) when any provider is missing.
|
||||
/// - `strict`: exit(1) when any CORE provider is missing (Phase 134 P1).
|
||||
/// - `quiet_pipe`: respect quiet JSON pipelines; we still write diagnostics to stderr only.
|
||||
/// - `label`: context label (e.g., "vm", "vm-fallback") for messages.
|
||||
pub fn check_and_report(strict: bool, quiet_pipe: bool, label: &str) {
|
||||
@ -67,14 +80,37 @@ pub fn check_and_report(strict: bool, quiet_pipe: bool, label: &str) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Phase 134 P1: In strict mode, fail-fast only if CORE providers are missing
|
||||
if strict {
|
||||
eprintln!(
|
||||
"❌ {} plugin-first strict: missing providers for: {:?}",
|
||||
label, missing
|
||||
);
|
||||
emit_hints_for(&missing);
|
||||
// Do not print anything to stdout in quiet mode; just exit with 1
|
||||
std::process::exit(1);
|
||||
let core_required = gather_core_required_providers();
|
||||
let core_missing: Vec<_> = missing
|
||||
.iter()
|
||||
.filter(|m| core_required.contains(m))
|
||||
.cloned()
|
||||
.collect();
|
||||
|
||||
if !core_missing.is_empty() {
|
||||
eprintln!(
|
||||
"❌ {} plugin-first strict: missing CORE providers: {:?}",
|
||||
label, core_missing
|
||||
);
|
||||
eprintln!(
|
||||
"[plugin/strict] Core providers are required: {:?}",
|
||||
core_required
|
||||
);
|
||||
emit_hints_for(&missing);
|
||||
// Do not print anything to stdout in quiet mode; just exit with 1
|
||||
std::process::exit(1);
|
||||
} else {
|
||||
// Strict mode but only non-core providers missing (e.g., FileBox, MapBox)
|
||||
// Log warning but continue
|
||||
eprintln!(
|
||||
"[plugin/missing] {} providers not loaded (non-core): {:?}",
|
||||
label, missing
|
||||
);
|
||||
eprintln!("[plugin/missing] hint: set NYASH_DEBUG_PLUGIN=1 or NYASH_CLI_VERBOSE=1 to see plugin init errors");
|
||||
emit_hints_for(&missing);
|
||||
}
|
||||
} else {
|
||||
eprintln!(
|
||||
"[plugin/missing] {} providers not loaded: {:?}",
|
||||
|
||||
Reference in New Issue
Block a user