From 51843230859ef39344c0b67daa9049ead87ec49c Mon Sep 17 00:00:00 2001 From: nsfisis Date: Tue, 2 Jun 2026 23:58:38 +0900 Subject: feat(resolver): port SecurityAdvisoryPoolFilter::filter Implement the security advisory pool filter end to end, plus the remaining actionable wirings it unblocked. - Unify the PartialSecurityAdvisory|SecurityAdvisory union as the PartialOrFullSecurityAdvisory enum and make the advisory types Clone, so advisories can be collected and stored; Pool.security_removed_versions now carries the union. This also unblocks PoolOptimizer's clone of the security-removed versions. - Thread the filter result through run_security_advisory_filter/build_pool as anyhow::Result. - Introduce typed PlatformRepositoryHandle and pass platform repos as handles through determine_requirements instead of &PlatformRepository. - Wire RuleSetGenerator's is_unacceptable_fixed_or_locked_package check and UpdateCommand's non-locked installed-packages branch. Co-Authored-By: Claude Opus 4.8 (1M context) --- crates/shirabe/src/repository/handle.rs | 64 +++++++++++++++++++++++++++++++-- 1 file changed, 61 insertions(+), 3 deletions(-) (limited to 'crates/shirabe/src/repository/handle.rs') diff --git a/crates/shirabe/src/repository/handle.rs b/crates/shirabe/src/repository/handle.rs index a4225f7..38a4f28 100644 --- a/crates/shirabe/src/repository/handle.rs +++ b/crates/shirabe/src/repository/handle.rs @@ -11,7 +11,8 @@ use crate::package::BasePackageHandle; use crate::package::PackageInterfaceHandle; use crate::repository::{ FindPackageConstraint, InstalledRepositoryInterface, LoadPackagesResult, LockArrayRepository, - ProviderInfo, RepositoryInterface, SearchResult, WritableRepositoryInterface, + PlatformRepository, ProviderInfo, RepositoryInterface, SearchResult, + WritableRepositoryInterface, }; /// Shared reference to a repository. Corresponds to PHP `RepositoryInterface`. @@ -173,8 +174,7 @@ impl std::hash::Hash for RepositoryInterfaceHandle { } } -/// Typed shared handle over `LockArrayRepository`. Preserves the PHP `?LockArrayRepository` -/// typing where a `RepositoryInterfaceHandle` would be too wide. +/// Typed shared handle over `LockArrayRepository`. #[derive(Debug, Clone)] pub struct LockArrayRepositoryHandle(Rc>); @@ -231,3 +231,61 @@ impl std::hash::Hash for LockArrayRepositoryHandle { self.ptr_id().hash(state); } } + +/// Typed shared handle over `PlatformRepository`. +#[derive(Debug, Clone)] +pub struct PlatformRepositoryHandle(Rc>); + +impl PlatformRepositoryHandle { + pub fn new(repository: PlatformRepository) -> Self { + let rc: Rc> = Rc::new(RefCell::new(repository)); + let rc_dyn: Rc> = rc.clone(); + rc.borrow().set_self_handle(Rc::downgrade(&rc_dyn)); + Self(rc) + } + + pub fn from_rc(rc: Rc>) -> Self { + Self(rc) + } + + pub fn as_rc(&self) -> &Rc> { + &self.0 + } + + pub fn borrow(&self) -> Ref<'_, PlatformRepository> { + self.0.borrow() + } + + pub fn borrow_mut(&self) -> RefMut<'_, PlatformRepository> { + self.0.borrow_mut() + } + + pub fn ptr_eq(&self, other: &Self) -> bool { + Rc::ptr_eq(&self.0, &other.0) + } + + pub fn ptr_id(&self) -> usize { + Rc::as_ptr(&self.0) as *const () as usize + } +} + +impl From for RepositoryInterfaceHandle { + fn from(h: PlatformRepositoryHandle) -> Self { + let rc: Rc> = h.0; + RepositoryInterfaceHandle::from_rc(rc) + } +} + +impl PartialEq for PlatformRepositoryHandle { + fn eq(&self, other: &Self) -> bool { + Rc::ptr_eq(&self.0, &other.0) + } +} + +impl Eq for PlatformRepositoryHandle {} + +impl std::hash::Hash for PlatformRepositoryHandle { + fn hash(&self, state: &mut H) { + self.ptr_id().hash(state); + } +} -- cgit v1.3.1