Skip to content

Commit cf6a12c

Browse files
authored
Add policy restriction overrides (#215)
1 parent 13f7b78 commit cf6a12c

5 files changed

Lines changed: 264 additions & 61 deletions

File tree

proto/hex_pb_policy.proto

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,9 @@ message RepositoryPolicy {
4141
// override (those bypass all limits).
4242
optional Restriction restriction = 2;
4343

44-
// Per-package final say, evaluated against each release in this repository.
45-
// An ALLOW override permits the release immediately and bypasses
46-
// `restriction`; a DENY override blocks it. When multiple overrides match a
47-
// release, the one with the most specific requirement wins.
44+
// Per-package overrides. ALLOW and DENY provide a final decision for the
45+
// matching release. ADVISORY, RETIREMENT, and COOLDOWN each bypass only the
46+
// selected restriction. Invalid or unknown entries are ignored.
4847
repeated Override overrides = 3;
4948
}
5049

@@ -58,8 +57,8 @@ message Restriction {
5857
repeated RetirementReason retirement_reasons = 2 [packed=true];
5958

6059
// Minimum release age. Same duration grammar as the Hex cooldown config
61-
// ("7d", "2w", "1mo", "0"). Unset or "0" = no minimum age. If multiple
62-
// active policies declare cooldowns, the effective cooldown is the strictest.
60+
// ("7d", "2w", "1mo", "0"). Unset or "0" = no minimum age. The active
61+
// policy and local cooldown compose by strictest-wins.
6362
optional string cooldown = 3;
6463
}
6564

@@ -72,16 +71,37 @@ message PackageRef {
7271
}
7372

7473
message Override {
75-
// Whether this override permits or blocks the matching release.
74+
// The effect of this override. The fields permitted for each action are
75+
// described below. Unknown actions must be ignored.
7676
required OverrideAction action = 1;
7777

7878
// The package (and optional requirement) the override applies to.
7979
required PackageRef ref = 2;
80+
81+
// ADVISORY requires advisory_id and forbids retirement_reason. Advisory
82+
// identifiers match primary advisory IDs and aliases without regard to
83+
// case. RETIREMENT requires retirement_reason and forbids advisory_id.
84+
// ALLOW, DENY, and COOLDOWN forbid both selector fields.
85+
optional string advisory_id = 3;
86+
optional RetirementReason retirement_reason = 4;
87+
88+
// Optional UTF-8 explanation surfaced by clients for every override action.
89+
// At most 500 Unicode code points; control, format, line separator, and
90+
// paragraph separator characters are invalid. This is public when the
91+
// policy visibility is VISIBILITY_PUBLIC.
92+
optional string comment = 5;
8093
}
8194

8295
enum OverrideAction {
83-
// Permit the release and bypass `restriction`.
96+
// Permit the release and bypass every policy restriction.
8497
OVERRIDE_ACTION_ALLOW = 0;
8598
// Block the release.
8699
OVERRIDE_ACTION_DENY = 1;
100+
// Accept only the advisory selected by advisory_id.
101+
OVERRIDE_ACTION_ADVISORY = 2;
102+
// Accept only a retirement with the selected retirement_reason.
103+
OVERRIDE_ACTION_RETIREMENT = 3;
104+
// Bypass only the policy cooldown. Local cooldown configuration still
105+
// applies independently.
106+
OVERRIDE_ACTION_COOLDOWN = 4;
87107
}

0 commit comments

Comments
 (0)