A
git:write scope grants write access. A ref policy can limit that access, but it cannot grant
access.kind: ref_policies on
remoteUrl in TypeScript and remote_url in Python, and RefPolicies on git.RemoteURL in Go.
Each SDK method also accepts them as a request option, and a client option sets them for every call.
See Ref policies on the SDK page.
Policy operations
Each SDK takes an operation as a plain string inops, for example 'no-push'.
Add a ref policy
The ref policies option is an ordered list of rules. Each rule has apattern and an optional ops
list.
This policy permits branches under agents/ in the default namespace. It rejects all other refs.
Set PIERRE_ORG and PIERRE_PRIVATE_KEY as shown in the
Quick Start.
ops permits its matched ref. Code Storage also permits a write when no rule
matches.
Add a final * rule with no-push when you need an allowlist. This rule rejects each ref that no
earlier rule permits.
Match refs
Use an exact ref or a prefix glob. A prefix glob has one final* after a slash. Use * to match
all refs.
Code Storage treats a pattern without refs/ as a branch name in the default namespace.
Code Storage uses the first rule whose pattern matches the ref. It does not check a later rule when
the first rule has no
ops.
Apply policies to ephemeral branches
Ref policies apply to ephemeral branches. Code Storage stores them in theephemeral ref namespace.
The policy sees the complete stored ref. For example, the ephemeral branch preview/pr-123 has this
ref:
preview/* pattern becomes refs/heads/preview/*. It matches branches in the default
namespace only.
This URL permits only ephemeral branches under
agents/:
Use a policy with an SDK call
Pass the same rules as a request option to an SDK method that writes a ref:refPolicies in
TypeScript, ref_policies in Python, and option.WithRefPolicies in Go. The SDK puts the rules in
the JWT for that call.
repos.branches.createandrepos.branches.deleterepos.tags.createandrepos.tags.deleterepos.commits.create,repos.commits.createFromDiff, andrepos.commits.restorerepos.mergeandrepos.upstream.pullrepos.notes.create,repos.notes.append, andrepos.notes.delete
Add a policy to a JWT
The SDK converts the ref policies to therefs JWT claim. Each claim entry is an ordered
[pattern, ops] pair.
Commit signature checks
Theverify-sig operation checks each commit that an update introduces to the matched ref. Code
Storage checks each signature against the registered organization keys.
A registered key does not enable a check by itself. Add verify-sig to a ref policy rule.
See Commit Signing for key setup, check behavior, and an example.
Where ref policies apply
Code Storage checks ref policies on these write paths:- A Git push over HTTPS
- A supported SDK or HTTP API method that updates a ref
Legacy ops option
A JWT can also hold a top-level ops claim. Code Storage adds these operations to the last *
rule, or adds a final * rule with them. The SDKs do not set this old claim.
Use the refs claim in new tokens. It shows the catch-all rule and supports specific refs.