Skip to content

Commit 6259cb3

Browse files
mikolalysenkoclaude
andcommitted
Mark every variant of a stale gem dir stale
/code-review high finding: a stale gem dir put only the variant named in its warning in stale_purls. The other platform variants stayed in assume_applied, and in-run VEX matches exemptions qualifier-insensitively, so they re-exempted the stale dir. Also drops a leftover blank line in the Node smoke test. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent e857bdf commit 6259cb3

2 files changed

Lines changed: 36 additions & 2 deletions

File tree

‎crates/socket-patch-cli/src/commands/scan/hosted.rs‎

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -551,7 +551,9 @@ async fn gem_stale_install_warnings(
551551
j.project_local,
552552
folded_cache.as_deref(),
553553
));
554-
out.stale_purls.insert(j.purl.clone());
554+
// Every variant installed in this dir: VEX matches its exemptions
555+
// qualifier-insensitively, so one left out would re-exempt the dir.
556+
out.stale_purls.extend(j.purls.iter().cloned());
555557
}
556558

557559
// Pass 3: standalone vendor/cache staleness — a committed archive whose
@@ -3358,6 +3360,39 @@ mod tests {
33583360
);
33593361
}
33603362

3363+
/// Platform variants of one gem share its installed dir: a stale dir
3364+
/// marks every variant stale, since the same-run VEX exempts purls
3365+
/// qualifier-insensitively and one left out would re-exempt the dir.
3366+
#[tokio::test]
3367+
async fn gem_stale_dir_marks_every_variant_stale() {
3368+
let tmp = tempfile::tempdir().unwrap();
3369+
materialize_gem(tmp.path(), GEM_UPSTREAM);
3370+
let variant = format!("{GEM_PURL}?platform=ruby");
3371+
let confirmed = vec![
3372+
(GEM_PURL.to_string(), GEM_UUID.to_string()),
3373+
(variant.clone(), "variant-uuid".to_string()),
3374+
];
3375+
let shas = std::collections::BTreeMap::from([(
3376+
("stale-unit".to_string(), "1.0.0".to_string()),
3377+
std::collections::BTreeSet::from(["0".repeat(64)]),
3378+
)]);
3379+
let out = gem_stale_install_warnings(
3380+
tmp.path(),
3381+
false,
3382+
None,
3383+
&confirmed,
3384+
&std::collections::BTreeMap::new(),
3385+
&shas,
3386+
&mut super::ViewFallback::offline(),
3387+
)
3388+
.await;
3389+
assert_eq!(out.warnings.len(), 1, "one dir, one warning");
3390+
assert_eq!(
3391+
out.stale_purls,
3392+
std::collections::BTreeSet::from([GEM_PURL.to_string(), variant])
3393+
);
3394+
}
3395+
33613396
/// A patch API whose view of `GEM_UUID` answers `status` (`gem_record()`
33623397
/// on 200), and a client pointed at it.
33633398
async fn gem_view_server(

‎crates/socket-patch-node/npm/test/smoke.mjs‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -433,7 +433,6 @@ test('not_found failures map per method like the HTTP API 404', async () => {
433433
assert.equal(references.project.error, undefined)
434434
assert.deepEqual(references.project.redirected, [])
435435

436-
437436
const batch = await run({ searchPatchesBatch: notFound })
438437
assert.equal(batch.project.error?.code, 'patch_lookup_failed')
439438
assert.match(batch.project.error.message, /not_found/)

0 commit comments

Comments
 (0)