Preserve plugin lifecycle JSON in G007 CLI output

Constraint: G007 worker integrations made plugin command JSON degraded-aware but omitted the structured plugin/load-failure arrays expected by inventory contracts.\nRejected: Drop lifecycle arrays from tests | G007 requires plugin lifecycle state to stay machine-readable across plugin surfaces.\nConfidence: high\nScope-risk: narrow\nDirective: Keep  carrying plugin entries, lifecycle state, and load failures even when config loading degrades.\nTested: cargo fmt --manifest-path rust/Cargo.toml --all -- --check; cargo check --manifest-path rust/Cargo.toml -p runtime -p tools -p rusty-claude-cli -p commands -p plugins; cargo test --manifest-path rust/Cargo.toml -p rusty-claude-cli --test output_format_contract plugins_json_surfaces_lifecycle_contract_when_plugin_is_installed -- --nocapture; cargo test --manifest-path rust/Cargo.toml -p rusty-claude-cli --test output_format_contract inventory_commands_emit_structured_json_when_requested -- --nocapture; git diff --check\nNot-tested: full workspace suite\n\nCo-authored-by: OmX <omx@oh-my-codex.dev>
This commit is contained in:
bellman
2026-05-15 09:56:46 +09:00
parent db91a235e9
commit c522dc970f
2 changed files with 27 additions and 5 deletions

View File

@@ -5620,6 +5620,8 @@ impl LiveCli {
"config_load_error": payload.config_load_error, "config_load_error": payload.config_load_error,
"message": payload.message, "message": payload.message,
"reload_runtime": payload.reload_runtime, "reload_runtime": payload.reload_runtime,
"plugins": payload.plugins,
"load_failures": payload.load_failures,
}))? }))?
), ),
} }
@@ -7744,6 +7746,8 @@ struct PluginsCommandPayload {
reload_runtime: bool, reload_runtime: bool,
status: &'static str, status: &'static str,
config_load_error: Option<String>, config_load_error: Option<String>,
plugins: Vec<Value>,
load_failures: Vec<Value>,
} }
fn plugins_command_payload_for( fn plugins_command_payload_for(
@@ -7758,17 +7762,30 @@ fn plugins_command_payload_for(
}; };
let mut manager = build_plugin_manager(cwd, &loader, &runtime_config); let mut manager = build_plugin_manager(cwd, &loader, &runtime_config);
let result = handle_plugins_slash_command(action, target, &mut manager)?; let result = handle_plugins_slash_command(action, target, &mut manager)?;
let report = manager.installed_plugin_registry_report()?;
Ok(plugins_command_payload_from_result( Ok(plugins_command_payload_from_result(
result, result,
config_load_error, config_load_error,
&report,
)) ))
} }
fn plugins_command_payload_from_result( fn plugins_command_payload_from_result(
result: PluginsCommandResult, result: PluginsCommandResult,
config_load_error: Option<String>, config_load_error: Option<String>,
report: &plugins::PluginRegistryReport,
) -> PluginsCommandPayload { ) -> PluginsCommandPayload {
let status = if config_load_error.is_some() { let load_failures = report
.failures()
.iter()
.map(plugin_load_failure_json)
.collect::<Vec<_>>();
let plugins = report
.summaries()
.iter()
.map(plugin_summary_json)
.collect::<Vec<_>>();
let status = if config_load_error.is_some() || !load_failures.is_empty() {
"degraded" "degraded"
} else { } else {
"ok" "ok"
@@ -7785,6 +7802,8 @@ fn plugins_command_payload_from_result(
reload_runtime: result.reload_runtime, reload_runtime: result.reload_runtime,
status, status,
config_load_error, config_load_error,
plugins,
load_failures,
} }
} }

View File

@@ -189,10 +189,13 @@ fn inventory_commands_emit_structured_json_when_requested() {
"plugins target should be null when no plugin is targeted" "plugins target should be null when no plugin is targeted"
); );
assert_eq!(plugins["status"], "ok"); assert_eq!(plugins["status"], "ok");
assert!(plugins["plugins"] let plugin_entries = plugins["plugins"].as_array().expect("plugins array");
.as_array() assert!(
.expect("plugins array") plugin_entries.iter().all(|plugin| plugin["id"].is_string()
.is_empty()); && plugin["lifecycle_state"].is_string()
&& plugin["lifecycle"].is_object()),
"plugins JSON entries should carry lifecycle contract fields"
);
assert!(plugins["load_failures"] assert!(plugins["load_failures"]
.as_array() .as_array()
.expect("plugin load failures array") .expect("plugin load failures array")