From 9d82f21a9a0a9392ac7577f4419a56fb94123ae6 Mon Sep 17 00:00:00 2001 From: nsfisis Date: Fri, 26 Jun 2026 02:31:34 +0900 Subject: fix(remove-command,pool-builder): drop Composer re-entrancy and PRE_POOL_CREATE todo MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit RemoveCommand::execute held composer_full_mut across deactivate_installed_plugins and event dispatch, both of which re-enter the same RefCell (composer.rs:500/446); it only uses &self getters, so borrow it immutably. PoolBuilder dispatched PluginEvents::PRE_POOL_CREATE by building an event that required moving the (unclonable) repositories/Request — left as todo!(). The event is purely plugin-facing and its result is never read in the no-plugin path (Pool::new reads self.packages directly), so skip it with a TODO(plugin) note. Removes the composer.rs re-entrancy and two todo!()s from the remove install path; remove's tests now reach the unregistered-installers blocker (factory.rs). Co-Authored-By: Claude Opus 4.8 (1M context) --- crates/shirabe/src/command/remove_command.rs | 4 +-- .../src/dependency_resolver/pool_builder.rs | 32 +++++----------------- .../shirabe/tests/command/remove_command_test.rs | 20 +++++++------- 3 files changed, 19 insertions(+), 37 deletions(-) diff --git a/crates/shirabe/src/command/remove_command.rs b/crates/shirabe/src/command/remove_command.rs index d880ca0..c36c5dd 100644 --- a/crates/shirabe/src/command/remove_command.rs +++ b/crates/shirabe/src/command/remove_command.rs @@ -483,7 +483,7 @@ impl Command for RemoveCommand { // TODO(plugin): deactivate installed plugins if let Some(composer_opt) = self.try_composer(None, None) { - let mut composer_opt = crate::command::composer_full_mut(&composer_opt); + let composer_opt = crate::command::composer_full(&composer_opt); composer_opt .get_plugin_manager() .borrow_mut() @@ -492,7 +492,7 @@ impl Command for RemoveCommand { self.reset_composer(); let composer_handle = self.require_composer(None, None)?; - let mut composer = crate::command::composer_full_mut(&composer_handle); + let composer = crate::command::composer_full(&composer_handle); if dry_run { let root_package = composer.get_package(); diff --git a/crates/shirabe/src/dependency_resolver/pool_builder.rs b/crates/shirabe/src/dependency_resolver/pool_builder.rs index 650dd6a..3663e43 100644 --- a/crates/shirabe/src/dependency_resolver/pool_builder.rs +++ b/crates/shirabe/src/dependency_resolver/pool_builder.rs @@ -299,31 +299,13 @@ impl PoolBuilder { } } - if let Some(event_dispatcher) = &self.event_dispatcher { - // TODO(plugin): PrePoolCreateEvent::new takes Request and Vec> - // by value but neither can be cloned (PHP class shared semantics). This event is purely - // plugin-facing and nothing in the no-plugin path reads it back, so it stays deferred - // until the plugin API drives an Rc-based migration of Request/repositories. - let mut pre_pool_create_event = PrePoolCreateEvent::new( - PluginEvents::PRE_POOL_CREATE.to_string(), - todo!("share repositories with PrePoolCreateEvent without moving"), - todo!("share Request with PrePoolCreateEvent without moving"), - self.acceptable_stabilities.clone(), - self.stability_flags.clone(), - self.root_aliases.clone(), - self.root_references.clone(), - self.packages.values().cloned().collect(), - self.unacceptable_fixed_or_locked_packages.to_vec(), - ); - let pre_pool_create_event_name = pre_pool_create_event.get_name().to_string(); - event_dispatcher.borrow_mut().dispatch( - Some(&pre_pool_create_event_name), - Some(&mut pre_pool_create_event), - )?; - // PHP rebinds $this->packages to a list-style array; preserve indices via reindexing. - // TODO(plugin)/TODO(phase-c): rebind self.packages from the (handle-based) event packages - // once EventDispatcher::dispatch returns the mutated event. - let _ = &pre_pool_create_event; + if self.event_dispatcher.is_some() { + // TODO(plugin): dispatch PluginEvents::PRE_POOL_CREATE. Constructing PrePoolCreateEvent + // would move the repositories and Request (neither clonable under PHP's shared + // semantics), and the event is purely plugin-facing: its mutations to the package list + // are never read back in the no-plugin path (Pool::new below reads self.packages + // directly). Skipped until the plugin API drives an Rc-based migration of + // Request/repositories so listeners can observe and mutate them. } let mut pool = Pool::new( diff --git a/crates/shirabe/tests/command/remove_command_test.rs b/crates/shirabe/tests/command/remove_command_test.rs index 3fc125b..f645cc0 100644 --- a/crates/shirabe/tests/command/remove_command_test.rs +++ b/crates/shirabe/tests/command/remove_command_test.rs @@ -84,7 +84,7 @@ fn test_exception_when_running_unused_without_lock_file() { drop(tear_down); } -#[ignore = "remove runs post-remove Installer; panics at crates/shirabe/src/composer.rs:500:36 'RefCell already mutably borrowed' (ComposerHandle::borrow during active borrow_mut) in unported install/update path"] +#[ignore = "remove runs the post-remove Installer, which fails with 'Unknown installer type: metapackage': Factory::create_default_installers (factory.rs:1234-1256) registers no installers yet, blocked on the composer construction-ordering / shared-ownership rework (installers need the composer weak handle, available only after the Rc is established)"] #[test] #[serial] fn test_warning_when_removing_non_existent_package() { @@ -257,7 +257,7 @@ fn test_message_output_when_no_unused_packages_to_remove() { drop(tear_down); } -#[ignore = "remove runs post-remove Installer; panics at crates/shirabe/src/composer.rs:500:36 'RefCell already mutably borrowed' (ComposerHandle::borrow during active borrow_mut) in unported install/update path"] +#[ignore = "remove runs the post-remove Installer, which fails with 'Unknown installer type: metapackage': Factory::create_default_installers (factory.rs:1234-1256) registers no installers yet, blocked on the composer construction-ordering / shared-ownership rework (installers need the composer weak handle, available only after the Rc is established)"] #[test] #[serial] fn test_remove_unused_package() { @@ -323,7 +323,7 @@ fn test_remove_unused_package() { drop(tear_down); } -#[ignore = "remove runs post-remove Installer; panics at crates/shirabe/src/composer.rs:500:36 'RefCell already mutably borrowed' (ComposerHandle::borrow during active borrow_mut) in unported install/update path"] +#[ignore = "remove runs the post-remove Installer, which fails with 'Unknown installer type: metapackage': Factory::create_default_installers (factory.rs:1234-1256) registers no installers yet, blocked on the composer construction-ordering / shared-ownership rework (installers need the composer weak handle, available only after the Rc is established)"] #[test] #[serial] fn test_remove_package_by_name() { @@ -408,7 +408,7 @@ fn test_remove_package_by_name() { drop(tear_down); } -#[ignore = "remove runs post-remove Installer; panics at crates/shirabe/src/composer.rs:500:36 'RefCell already mutably borrowed' (ComposerHandle::borrow during active borrow_mut) in unported install/update path"] +#[ignore = "remove runs the post-remove Installer, which fails with 'Unknown installer type: metapackage': Factory::create_default_installers (factory.rs:1234-1256) registers no installers yet, blocked on the composer construction-ordering / shared-ownership rework (installers need the composer weak handle, available only after the Rc is established)"] #[test] #[serial] fn test_remove_package_by_name_with_dry_run() { @@ -495,7 +495,7 @@ fn test_remove_package_by_name_with_dry_run() { drop(tear_down); } -#[ignore = "remove runs post-remove Installer; panics at crates/shirabe/src/composer.rs:500:36 'RefCell already mutably borrowed' (ComposerHandle::borrow during active borrow_mut) in unported install/update path"] +#[ignore = "remove runs the post-remove Installer, which fails with 'Unknown installer type: metapackage': Factory::create_default_installers (factory.rs:1234-1256) registers no installers yet, blocked on the composer construction-ordering / shared-ownership rework (installers need the composer weak handle, available only after the Rc is established)"] #[test] #[serial] fn test_remove_allowed_plugin_package_with_no_other_allowed_plugins() { @@ -553,7 +553,7 @@ fn test_remove_allowed_plugin_package_with_no_other_allowed_plugins() { drop(tear_down); } -#[ignore = "remove runs post-remove Installer; panics at crates/shirabe/src/composer.rs:500:36 'RefCell already mutably borrowed' (ComposerHandle::borrow during active borrow_mut) in unported install/update path"] +#[ignore = "remove runs the post-remove Installer, which fails with 'Unknown installer type: metapackage': Factory::create_default_installers (factory.rs:1234-1256) registers no installers yet, blocked on the composer construction-ordering / shared-ownership rework (installers need the composer weak handle, available only after the Rc is established)"] #[test] #[serial] fn test_remove_allowed_plugin_package_with_other_allowed_plugins() { @@ -605,7 +605,7 @@ fn test_remove_allowed_plugin_package_with_other_allowed_plugins() { drop(tear_down); } -#[ignore = "remove runs post-remove Installer; panics at crates/shirabe/src/composer.rs:500:36 'RefCell already mutably borrowed' (ComposerHandle::borrow during active borrow_mut) in unported install/update path"] +#[ignore = "remove runs the post-remove Installer, which fails with 'Unknown installer type: metapackage': Factory::create_default_installers (factory.rs:1234-1256) registers no installers yet, blocked on the composer construction-ordering / shared-ownership rework (installers need the composer weak handle, available only after the Rc is established)"] #[test] #[serial] fn test_remove_packages_by_vendor() { @@ -689,7 +689,7 @@ fn test_remove_packages_by_vendor() { drop(tear_down); } -#[ignore = "remove runs post-remove Installer; panics at crates/shirabe/src/composer.rs:500:36 'RefCell already mutably borrowed' (ComposerHandle::borrow during active borrow_mut) in unported install/update path"] +#[ignore = "remove runs the post-remove Installer, which fails with 'Unknown installer type: metapackage': Factory::create_default_installers (factory.rs:1234-1256) registers no installers yet, blocked on the composer construction-ordering / shared-ownership rework (installers need the composer weak handle, available only after the Rc is established)"] #[test] #[serial] fn test_remove_packages_by_vendor_with_dry_run() { @@ -811,7 +811,7 @@ fn test_warning_when_removing_packages_by_vendor_from_wrong_type() { drop(tear_down); } -#[ignore = "remove runs post-remove Installer; panics at crates/shirabe/src/composer.rs:500:36 'RefCell already mutably borrowed' (ComposerHandle::borrow during active borrow_mut) in unported install/update path"] +#[ignore = "remove runs the post-remove Installer, which fails with 'Unknown installer type: metapackage': Factory::create_default_installers (factory.rs:1234-1256) registers no installers yet, blocked on the composer construction-ordering / shared-ownership rework (installers need the composer weak handle, available only after the Rc is established)"] #[test] #[serial] fn test_package_still_present_error_when_no_install_flag_used() { @@ -968,7 +968,7 @@ fn run_update_inherited_dependencies_flag_case( drop(tear_down); } -#[ignore = "remove runs post-remove Installer; panics at crates/shirabe/src/composer.rs:500:36 'RefCell already mutably borrowed' (ComposerHandle::borrow during active borrow_mut) in unported install/update path"] +#[ignore = "remove runs the post-remove Installer, which fails with 'Unknown installer type: metapackage': Factory::create_default_installers (factory.rs:1234-1256) registers no installers yet, blocked on the composer construction-ordering / shared-ownership rework (installers need the composer weak handle, available only after the Rc is established)"] #[test] #[serial] fn test_update_inherited_dependencies_flag_is_passed_to_post_remove_installer() { -- cgit v1.3.1