diff options
| author | nsfisis <nsfisis@gmail.com> | 2026-06-02 23:58:38 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2026-06-02 23:58:54 +0900 |
| commit | 51843230859ef39344c0b67daa9049ead87ec49c (patch) | |
| tree | f657969816da51b7f8656012e756498680ffcc23 /crates/shirabe/src/repository/handle.rs | |
| parent | 20dbcf11b86cb03c451ba1d5cd9efe17b68fa66d (diff) | |
| download | php-shirabe-51843230859ef39344c0b67daa9049ead87ec49c.tar.gz php-shirabe-51843230859ef39344c0b67daa9049ead87ec49c.tar.zst php-shirabe-51843230859ef39344c0b67daa9049ead87ec49c.zip | |
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) <noreply@anthropic.com>
Diffstat (limited to 'crates/shirabe/src/repository/handle.rs')
| -rw-r--r-- | crates/shirabe/src/repository/handle.rs | 64 |
1 files changed, 61 insertions, 3 deletions
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<RefCell<LockArrayRepository>>); @@ -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<RefCell<PlatformRepository>>); + +impl PlatformRepositoryHandle { + pub fn new(repository: PlatformRepository) -> Self { + let rc: Rc<RefCell<PlatformRepository>> = Rc::new(RefCell::new(repository)); + let rc_dyn: Rc<RefCell<dyn RepositoryInterface>> = rc.clone(); + rc.borrow().set_self_handle(Rc::downgrade(&rc_dyn)); + Self(rc) + } + + pub fn from_rc(rc: Rc<RefCell<PlatformRepository>>) -> Self { + Self(rc) + } + + pub fn as_rc(&self) -> &Rc<RefCell<PlatformRepository>> { + &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<PlatformRepositoryHandle> for RepositoryInterfaceHandle { + fn from(h: PlatformRepositoryHandle) -> Self { + let rc: Rc<RefCell<dyn RepositoryInterface>> = 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<H: std::hash::Hasher>(&self, state: &mut H) { + self.ptr_id().hash(state); + } +} |
