You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Apply cooldown to Swift releases that have publishedAt - #820
Part of #814. Swift releases are held back by cooldown when the upstream sends publishedAt, as discussed there.
The release list has no times, so each release's publishedAt is read from its release document, from the highest version down to the first release that is old enough or has no time, and stored.
Releases in cooldown are left out of the list, and a latest-version link to one is dropped. Their release document, Package.swift and source archive get 403.
A release without publishedAt is let through. The default upstream (tuist.dev) doesn't send it, so with it nothing changes: I checked apple/swift-nio against tuist.dev with a 3d cooldown and all 197 releases are listed.
Cooldown rules name packages as pkg:swift/{scope}/{name}, case-insensitive. packageurl.MakeString returns "" for a registry identity, so the package page now builds the same PURL through handler.CooldownPackagePURL.
Summary by CodeRabbit
New Features
Swift packages now support release cooldowns. Recently published releases are omitted from version listings and blocked when requested directly; older releases remain available.
Cooldowns use Swift’s optional publication timestamp. Releases without a timestamp aren’t filtered by cooldown, and packages with cooldowns disabled remain unaffected.
Swift packages can use package-specific cooldown settings and patterns, with unmatched packages using the configured default.
When a release is withheld, its latest-version link is removed from the listing.
The release document's optional publishedAt is the only time the Swift
registry API has. Releases in cooldown are left out of the release list,
with a latest-version link to one, and their metadata, manifests and
source archive get 403. A release without publishedAt is let through, so
with the default upstream, which doesn't send it, nothing changes.
Times are read from the highest version down to the first release that is
old enough or has no time, and stored. Cooldown rules name packages as
pkg:swift/{scope}/{name}, which the package page now uses too.
No actionable comments were generated in the recent review.
Walkthrough
Adds Swift release cooldown support. The proxy filters release lists using optional publishedAt timestamps, records withheld releases, and blocks requests for those releases.
Changes: Swift release cooldown
Layer / File(s)
Summary
Swift policy identity and matching internal/handler/handler.go, internal/packageurl/*, internal/server/cooldown_view*
Swift is listed as cooldown-supported. Swift package PURLs support policy lookup, and Swift policy matching is case-insensitive.
Swift release filtering internal/metadata/swift/*
The metadata package parses publishedAt, filters eligible releases from highest version downward, and removes latest-version links for withheld releases. Tests cover filtering, timestamp parsing, and link handling.
Swift request handling and documentation internal/handler/swift.go, internal/handler/swift_cooldown*, README.md, docs/configuration.md
Swift handlers filter release lists, record withheld releases, and block requests for withheld releases. Tests and documentation cover filtering, blocked responses, lookup failures, and timestamp behavior.
sequenceDiagram
participant SwiftClient
participant SwiftHandler
participant SwiftCooldown
participant CooldownDatabase
participant SwiftRegistry
SwiftClient->>SwiftHandler: Request package release index
SwiftHandler->>SwiftCooldown: Filter release metadata
SwiftCooldown->>CooldownDatabase: Read stored publication time
SwiftCooldown->>SwiftRegistry: Fetch release document when time is unavailable
SwiftRegistry-->>SwiftCooldown: Return publishedAt value
SwiftCooldown->>CooldownDatabase: Store nonzero publication time
SwiftCooldown->>CooldownDatabase: Record withheld release
SwiftCooldown-->>SwiftHandler: Return filtered metadata
SwiftHandler-->>SwiftClient: Return release index
Loading
Possibly related issues
git-pkgs/proxy#814: This PR adds Swift cooldown using publishedAt when present and allows releases without it. The issue’s separate Chef request is not addressed.
git-pkgs/proxy#132: This PR adds cooldown filtering to Swift release lists. Other ecosystems listed in the issue are outside this change.
Possibly related PRs
git-pkgs/proxy#722: This PR uses the shared withheld-version recording path introduced by that PR.
Suggested reviewers:andrew
Merge Risk: Minimal · up to 4260e
Swift packages can now be held back during the cooldown period when the upstream provides publishedAt. Releases in cooldown are left out of the list and their requests get a 403. Releases without timestamps pass through, which the docs state, and one documented limitation remains: a backport published after a newer allowed release stays listed but is refused. No merge-blocking issue was found.
Pre-merge checks: 4
Check name
Status
Explanation
Description Check
Check skipped - CodeRabbit’s high-level summary is enabled.
Title check
The title names the main change: cooldown is applied to Swift releases that carry a publishedAt value. The raw summary and objectives confirm that the changeset filters Swift release lists, blocks coo…
Linked Issues check
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
Check skipped because no linked issues were found for this pull request.
Full details: Title check
Explanation
The title names the main change: cooldown is applied to Swift releases that carry a publishedAt value. The raw summary and objectives confirm that the changeset filters Swift release lists, blocks cooldown releases with 403, and reads publishedAt from release metadata. The title is specific and concise, and it has no file lists or vague terms.
Finishing Touches
Generate unit tests (beta)
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
File: No configuration file from this repository applied
Commit: Unavailable
Layers: Organization UI
Review profile: CHILL
Plan: Advanced
Run ID: 1598e6f1-1ca4-49b0-aa26-cf5c97219ccd
Commits
Reviewing files that changed from the base of the PR and between 9f333a2 and 4260ec6.
Files selected for processing: 4
docs/configuration.md
internal/handler/swift_cooldown.go
internal/metadata/swift/cooldown.go
internal/metadata/swift/cooldown_test.go
Files skipped from review as they are similar to previous changes: 1
docs/configuration.md
Included review availability: This review used your included allowance. Your plan provides up to 2 included reviews per hour; 1 remain after this review.
The reason will be displayed to describe this comment to others. Learn more.
Additional comments: 1
internal/metadata/swift/cooldown.go-145-145: 1
145-145: Minor · Functional Correctness · Quick win
Unverified finding
Verification ran but could not confirm this finding. It is shown for review, not as a verified issue.
Compare the link's release identity, not its raw final component.
If a withheld 1.2.0 uses a latest-version target ending in /1.2.0.json, this extracts 1.2.0.json. The lookup misses removed["1.2.0"], so the forbidden release remains linked. Swift permits the .json document URI. (raw.githubusercontent.com)
Parse the target URI and normalize the release-document suffix before comparison. Add a case that removes the .json link and preserves a link to an unremoved version.
Review info
Run configuration
Source mode: Auto
Repository: Unavailable
Branch: Unavailable
File: No configuration file from this repository applied
Commit: Unavailable
Layers: Organization UI
Review profile: CHILL
Plan: Advanced
Run ID: a519652e-1d42-4475-85bb-d7d514342d80
Commits
Reviewing files that changed from the base of the PR and between ef0e860 and 9f333a2.
Files selected for processing: 13
README.md
docs/configuration.md
internal/handler/handler.go
internal/handler/swift.go
internal/handler/swift_cooldown.go
internal/handler/swift_cooldown_test.go
internal/metadata/swift/cooldown.go
internal/metadata/swift/cooldown_test.go
internal/metadata/swift/imports_test.go
internal/packageurl/packageurl.go
internal/packageurl/packageurl_test.go
internal/server/cooldown_view.go
internal/server/cooldown_view_test.go
Included review availability: This review used your included allowance. Your plan provides up to 2 included reviews per hour; 1 remain after this review.
@coderabbitai Right about the latest-version target: fixed in 366c544. The release is read from the parsed URL's last path segment without .json, so /1.2.0.json and /1.2.0?x=1 are dropped too, and a link to a release left in the list stays.
For best results, initiate chat on the files or code changes.
Analysis chain
Script executed:
#!/bin/bashprintf'%s\n''--- Current revision ---'
git rev-parse HEAD
printf'%s\n''--- Reported commit ---'
git show --format=fuller --stat --no-renames 366c544 -- 2>&1| head -100
printf'%s\n''--- Implementation outline ---'
ast-grep outline internal/metadata/swift/cooldown.go --items all --match 'WithoutLatestVersion|latest' --view expanded
printf'%s\n''--- Implementation and tests ---'
rg -n -C 18 'func WithoutLatestVersion|func TestWithoutLatestVersion|1\.2\.0\.json|1\.2\.0\?x=1|latest-version' internal/metadata/swift/cooldown.go internal/metadata/swift/cooldown_test.go internal/handler/swift.go internal/handler/swift_cooldown_test.go
Length of output: 18119
@simonchrz Thanks for the fix. I inspected 366c544: it handles .json and query-string targets and preserves links to releases that remain listed. The tests cover those cases, but I did not run them.
I’ll leave thread resolution to you.
If you found this review helpful, would you consider giving us a shout-out on X?
The reason will be displayed to describe this comment to others. Learn more.
The walk ends at the first release that is old enough, in semver order, so an old prerelease above the current stable line ends it straight away. Take a package with a months-old 3.0.0-alpha.1 and an active 2.x line: the alpha is checked first and allowed, the walk stops, and a 2.5.1 published an hour ago stays in the list but gets 403. swift package update picks it and fails instead of resolving to 2.5.0.
The docs describe this for a backport to an older release line, but a lingering prerelease is the more common way to hit it. An allowed prerelease shouldn't end the walk; only an allowed stable release should. That needs a test case alongside TestFilterReleasesWithholdsReleasesInCooldown.
The reason will be displayed to describe this comment to others. Learn more.
This block repeats the Swift paragraph in docs/configuration.md; delete it. The comment on checkCooldown (lines 81-84) can be cut to its first sentence.
The walk ended at the first release out of cooldown, so a months-old prerelease above the stable line hid a new stable release from it. Only a stable release that is old enough ends it now. Also drop the comment that repeated the docs.
An allowed prerelease no longer ends the walk; only an allowed stable release does. TestFilterReleasesLooksPastAnOldPrerelease covers your case: 3.0.0-alpha.1 is months old, 2.5.1 is an hour old and is left out, and the walk stops at 2.5.0. The docs say so too.
Removed the header comment and cut the one on checkCooldown to its first sentence.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of #814. Swift releases are held back by cooldown when the upstream sends
publishedAt, as discussed there.publishedAtis read from its release document, from the highest version down to the first release that is old enough or has no time, and stored.latest-versionlink to one is dropped. Their release document,Package.swiftand source archive get 403.publishedAtis let through. The default upstream (tuist.dev) doesn't send it, so with it nothing changes: I checkedapple/swift-nioagainst tuist.dev with a 3d cooldown and all 197 releases are listed.pkg:swift/{scope}/{name}, case-insensitive.packageurl.MakeStringreturns "" for a registry identity, so the package page now builds the same PURL throughhandler.CooldownPackagePURL.Summary by CodeRabbit
latest-versionlink is removed from the listing.