Skip to content

Restructure Policy into per-repository restrictions and overrides#194

Merged
ericmj merged 2 commits into
mainfrom
policy-rules
Jun 17, 2026
Merged

Restructure Policy into per-repository restrictions and overrides#194
ericmj merged 2 commits into
mainfrom
policy-rules

Conversation

@ericmj

@ericmj ericmj commented Jun 7, 2026

Copy link
Copy Markdown
Member

Replace the ordered Rule list with a repeated RepositoryPolicy, one entry per repository the policy constrains (in practice "hexpm" and the org's own repository). Each entry has:

  • restriction — baseline advisory_min_severity / retirement_reasons / cooldown limits applied to every release in the repository
  • overrides — per-package ALLOW/DENY with an optional requirement

For each candidate release the client matches the entry for its repository, then evaluates overrides (most specific requirement wins; ALLOW bypasses the restriction, DENY blocks), then the restriction. An ALLOW override is exempt from the restriction; everything else in the repository is subject to it. The Filter, Rule, oneof action, and Availability messages are gone.

visibility is unchanged. Regenerate hex_pb_policy.erl and update the policy test fixtures.

Also see hexpm/specifications#62.

Replace the ordered Rule list with a repeated RepositoryPolicy, one entry
per repository the policy constrains (in practice "hexpm" and the org's own
repository). Each entry has:

  * restriction — baseline advisory_min_severity / retirement_reasons /
    cooldown limits applied to every release in the repository
  * overrides — per-package ALLOW/DENY with an optional requirement

For each candidate release the client matches the entry for its repository,
then evaluates overrides (most specific requirement wins; ALLOW bypasses the
restriction, DENY blocks), then the restriction. An ALLOW override is exempt
from the restriction; everything else in the repository is subject to it. The
Filter, Rule, oneof action, and Availability messages are gone.

Restriction imports package.proto and types advisory_min_severity and
retirement_reasons as the AdvisorySeverity and RetirementReason enums rather
than bare uint32, so the values are symbolic. This is wire-identical to
uint32 (proto2 enums encode as varints) and still decodes unknown future
values as integers.

visibility is unchanged. Regenerate hex_pb_policy.erl and update the policy
test fixtures.
@ericmj ericmj marked this pull request as ready for review June 8, 2026 16:22
Comment thread src/hex_core.erl
get_policy required repo_organization and errored without it, forcing
clients that store the full repository URL (with /repos/<org> already
baked in) to strip the suffix back off to satisfy it. Build the URL
through the shared build_url path like get_package: repo_organization
still inserts /repos/<org> when set, and clients that bake it into
repo_url reach the same resource with the field unset.
@ericmj ericmj merged commit d6a6a5a into main Jun 17, 2026
10 checks passed
@ericmj ericmj deleted the policy-rules branch June 17, 2026 08:27
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.

2 participants