Skip to content

Dependency policies#190

Draft
ericmj wants to merge 9 commits into
mainfrom
dependency-policies
Draft

Dependency policies#190
ericmj wants to merge 9 commits into
mainfrom
dependency-policies

Conversation

@ericmj
Copy link
Copy Markdown
Member

@ericmj ericmj commented May 22, 2026

No description provided.

ericmj added 9 commits May 21, 2026 01:23
Generates hex_pb_policy.erl from the new policy.proto in
specifications. hex_registry gains encode_policy/decode_policy/
build_policy/unpack_policy; hex_repo gains get_policy/2 for
fetching /repos/<org>/policies/<name>. Round-trip and HTTP
fixture tests cover signed payload verification, repository/name
mismatch errors, and the no_verify path.
Policies only exist per-organization, so calling get_policy/2 without
repo_organization set was silently falling back to the global path and
returning a misleading bad_repo_name. Raise a clear error instead.
Extend tests to cover the new error path and the no_verify unpack path.
decode_policy/3 now matches published_at as a shape witness, matching
the pattern that decode_package/3 (releases) and decode_names/2 /
decode_versions/2 (packages) use to detect corrupt or mis-routed
payloads.

get_policy/2 returns {error, missing_repo_organization} when
repo_organization is unset, matching the tagged-tuple error idiom
the rest of the module uses. The embedded English string and the
ad-hoc error/1 raise are dropped.
Mirrors the change in specifications. Field 4 is reserved on the
wire. The decode_policy/3 shape witness moves from published_at to
visibility (also required). Fixtures and tests updated.
Mirrors the renumbering in specifications. The proto was unreleased
so back-compat reservations are dead weight.
The Org binding from the case clause is equivalent to repo_name(Config)
inside this branch (repo_name/1 returns repo_organization when set), so
use it directly and drop the indirection.
visibility is required by the proto, so the pattern always binds it.
Keep only the repository/name checks that match against the verifier
inputs.
?CONFIG never sets repo_organization, so removing it was misleading.
Use ?CONFIG directly — the absence of the key is what the test exercises.
Mention the {error, missing_repo_organization} return so the doc covers
both the success and absence-of-config cases.
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.

1 participant