|
4 | 4 | removeDeclaredPackageRepo, |
5 | 5 | updatePackagistPackageStats, |
6 | 6 | upsertPackageMaintainers, |
7 | | - upsertPackageRepo, |
| 7 | + upsertPackageRepoPreserveProvenance, |
8 | 8 | } from '@crowd/data-access-layer/src/packages' |
9 | 9 | import type { QueryExecutor } from '@crowd/data-access-layer/src/queryExecutor' |
10 | 10 |
|
@@ -61,14 +61,18 @@ export async function persistPackagistPackageInfo( |
61 | 61 | changedFields.push(...result.changedFields) |
62 | 62 |
|
63 | 63 | // Step 2: Link the repo for ALL packages — 'declared'/0.8 is the manifest-declared |
64 | | - // convention shared by npm/pypi/maven/cargo. When there's no trusted repo (removed |
65 | | - // from the manifest, or no longer canonicalizable to a known host), or it now |
66 | | - // resolves to a different repo, clear any previously-declared link that no longer |
67 | | - // applies — package_repos' unique key is (package_id, repo_id), not (package_id, |
68 | | - // source), so upserting the new link alone would leave a stale one dangling. |
| 64 | + // convention shared by npm/pypi/maven/cargo. Preserve-provenance: a higher-confidence |
| 65 | + // link another pipeline (manual/deps_dev) already owns for this repo must not be |
| 66 | + // downgraded to 'declared'/0.8 by a routine weekly refresh — matches |
| 67 | + // upsertMavenPackageRepo/cargo's established GREATEST-confidence, source-preserving |
| 68 | + // pattern. When there's no trusted repo (removed from the manifest, or no longer |
| 69 | + // canonicalizable to a known host), or it now resolves to a different repo, clear any |
| 70 | + // previously-declared link that no longer applies — package_repos' unique key is |
| 71 | + // (package_id, repo_id), not (package_id, source), so upserting the new link alone |
| 72 | + // would leave a stale one dangling. |
69 | 73 | if (trustedRepo) { |
70 | 74 | const repo = await getOrCreateRepoByUrl(t, trustedRepo.url, trustedRepo.host) |
71 | | - const linkChanged = await upsertPackageRepo(t, id, repo.id, 'declared', 0.8) |
| 75 | + const linkChanged = await upsertPackageRepoPreserveProvenance(t, id, repo.id, 'declared', 0.8) |
72 | 76 | const removedFields = await removeDeclaredPackageRepo(t, id, repo.id) |
73 | 77 | changedFields.push(...repo.changedFields, ...linkChanged, ...removedFields) |
74 | 78 | } else { |
|
0 commit comments