Skip to content

feat: adds a configurable PolicyFetcher - #73

Open
jvolkman wants to merge 1 commit into
buildbarn:mainfrom
jvolkman:dev/fetch-policy
Open

feat: adds a configurable PolicyFetcher#73
jvolkman wants to merge 1 commit into
buildbarn:mainfrom
jvolkman:dev/fetch-policy

Conversation

@jvolkman

@jvolkman jvolkman commented May 16, 2026

Copy link
Copy Markdown
Contributor

Introduces a "fetch policy" feature to control remote asset downloads based on URI patterns.

Rules match URIs with regular expressions and assign an action, one of:

  • ACCEPT: Normal caching behavior.
  • ACCEPT_REFRESH: Uses oldest_content_accepted to force a remote fetch.
  • DENY: Blocks the download.

The first matching rule for each URI wins. No matching rules is a default ACCEPT. If multiple URIs are passed in a single fetch request, each is considered individually. If one URI matches a DENY and the other does not, the accepted URI will still be fetched.

PolicyFetcher groups ACCEPT and ACCEPT_REFRESH URIs together and passes each group separately to the downstream fetcher - starting with the ACCEPT bucket - such that oldest_content_accepted can be set on the ACCEPT_REFRESH bucket.

Example config:

{
  "fetcher": {
    "policy": {
      "rules": [
        { "uri_regex": "^https://github[.]com/blocked-org/safe_file.txt", "action": "ACCEPT" },
        { "uri_regex": "^https://github[.]com/blocked-org/.*", "action": "DENY" },
        { "uri_regex": "^https://github[.]com/mutable-org/.*", "action": "ACCEPT_REFRESH" },
      ]
    }
  }
}

More context in slack - https://buildteamworld.slack.com/archives/CD6HZC750/p1778956175968159

Introduces a "fetch policy" feature to control remote asset downloads based on
URI patterns.

Rules match URIs with regular expressions and assign an action, one of:
  - ACCEPT: Normal caching behavior.
  - ACCEPT_REFRESH: Uses oldest_content_accepted to force a remote fetch.
  - DENY: Blocks the download.

The first matching rule for each URI wins. No matching rules is a
default ACCEPT. If multiple URIs are passed in a single fetch request,
each is considered individually. If one URI matches a DENY and the other
does not, the accepted URI will still be fetched.

PolicyFetcher groups ACCEPT and ACCEPT_REFRESH URIs together and passes
each group separately to the downstream fetcher - starting with the ACCEPT
bucket - such that oldest_content_accepted can be set on the ACCEPT_REFRESH
bucket.

Example config:
```json
{
  fetcher: {
    policy: {
      rules: [
        { "uri_regex": "^https://github[.]com/blocked-org/safe_file.txt", "action": "ACCEPT" },
        { "uri_regex": "^https://github[.]com/blocked-org/.*", "action": "DENY" },
        { "uri_regex": "^https://github[.]com/mutable-org/.*", "action": "ACCEPT_REFRESH" },
      ]
    }
  }
}
```
@EdSchouten

Copy link
Copy Markdown
Member

Is anyone looking into this PR? @mortenmj ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants