Repository navigation
✨ Reference repos: per-hive write identity, bot / bot only / owner (backend) (#18516) - #18521
Conversation
…8516) project.remote_write_identity picks whose name a granted write-tier reference repo's issues, PRs and comments carry: - bot (default; a missing key reads as bot): the hive's GitHub App bot on a repo whose owner installed the App themselves (GET /repos/{o}/{r}/installation with the App JWT, cached like org discovery), else the owner's connected account, else read-only. - bot_only: the App bot where installed, read-only elsewhere; the owner token is never read. - owner: the owner's connected account everywhere (the #18197 behaviour). The setting never widens a grant: only entries already at the write tier (hand-written or derived from an accepted request issue, #18139) get a token source, so an App installation shared by many hives is not a grant by itself. The bot token is minted on the installation covering that one repo, scoped to that repo and to the tier's permissions (metadata read; issues write; contents and pull_requests write for prs), cached until near expiry, and injected only by the existing reference-repo proxy path. A transient lookup failure serves the entry read-only for the pass (state unresolved) instead of silently switching identity. write_token_file still wins on hand-written entries. Every proxy refusal is unchanged; a bot login never names a fork, so bot PR branches go to the repo itself under the default-branch guard. The kick names the bot flow (no fork) beside the owner fork flow, the request-issue read-only notice names no cure under bot_only, and the own-item follow-up poller keeps to owner-identity repos. Refs #18516 Signed-off-by: Andy Anderson <andy@clubanderson.com>
Open PR overlap checkBase branch: Conflicts are checked with every PR merged onto the current tip of
|
…sient App lookup (#18516) The resolved list replaces the config in memory and the editor saves from it, so clearing Write on a blip would persist as an edit. The entry keeps Write, is marked unresolved, and gets a read-only proxy policy for the pass; the kick says it is read-only this pass. Signed-off-by: Andy Anderson <andy@clubanderson.com>
Mutation testing⏱️ The 900s mutation budget ran out, so 1 package(s) were not fully mutated and the results below do not cover them:
❌ gremlins did not produce a report for 1 package(s), so no verdict can be derived from this run (see the job log):
2 mutant(s) in changed files are not reached by any test (NOT COVERED). A maintainer may apply the
ℹ️ 4 mutant(s) on added lines were SKIPPED because gremlins v0.6.0 only honours the first
Verdict: |
|
@nate-double-u FYI, backend for the bot / bot only / owner setting (#18516). Once this and the Settings UI land, pick "Hive bot only" under Settings, Repos, Reference repos. |
|
[APPROVALNOTIFIER] This PR is APPROVED Approval requirements bypassed by manually added approval. This pull-request has been approved by: The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
There was a problem hiding this comment.
Style review (head 2acf6cb) — no in-scope blocker; three advisory notes.
-
Bot detection by string suffix in the proxy (
src/crux/proxy/reference_repos.go,forkSlug):strings.HasSuffix(r.Login, "[bot]")re-derives "this is the App identity" from the login text, while the PR already models that asconfig.ReferenceIdentityBot(src/pkg/config/remote_write_identity.go) and sets it incmd/hive/reference_repos.go. Two sources of truth for one fact. Consider an explicit field onproxy.ReferenceRepoPolicy(e.g.NoFork bool/Identity) set wherepol.Tokenis chosen, so the proxy does not parse logins. -
Constructing a throwaway
ProjectConfigto normalise a string (src/pkg/github/reference_repo_identity.go,mode := (config.ProjectConfig{RemoteWriteIdentity: setting}).EffectiveRemoteWriteIdentity()). The effective-value logic lives onProjectConfigonly because the field does. A package-levelconfig.EffectiveRemoteWriteIdentity(v string) stringthat the method delegates to would read more directly at this call site. -
Allowlist placement (
src/pkg/dashboard/settings_parity_allowlist.txt:624):project.remote_write_identityis inserted in the middle of theproject.workflow_bindings[]group, so its neighbours do not relate to it. Move it next to the otherproject.*reference-repo/settings entries, or keep it, but it breaks the grouping.
— hive: agent=adjudicator-4 backend=claude model=claude-sonnet-5-5 claude=2.1.325
|
Hive status — updated in place; edits do not notify. Full history is in the Activity Monitor. Review findings from Docs-currency review (head 2acf6cb) — changes requested; the PR defers docs to part 2, but it flips the default behaviour now, so three operator docs become false on merge.
Add one
Limits: I did not check whether a doc-parity test enforces operator-reference rows for new config keys. Review findings from Security review (head 2acf6cb) — one in-scope blocker. 1. Bot identity widens the push gate from "own fork" to "any non-default ref on the upstream repo" (medium-high)
Consequence: a prompt-injected or misbehaving agent can use the bot token to:
That breaks the documented contract ("push a topic branch and open a PR") on a third party's repo. Bot is the default setting, so this is the common path. The PR's own tests don't cover it. Requested fix: for a bot-identity policy, restrict pushes to topic branches that are new and namespaced, and refuse deletes and tags. for _, ref := range refs {
if ref == "refs/heads/"+def {
return referenceRepoRefusal(pol, "pushing to its default branch ("+def+") is never allowed — push a topic branch and open a PR"), true
}
+ if strings.HasSuffix(pol.Login, "[bot]") && !strings.HasPrefix(ref, "refs/heads/hive/") {
+ return referenceRepoRefusal(pol, "the bot identity may only create topic branches named hive/<topic>"), true
+ }
}and in Minor (info, no verdict impact)
Not verified: the real Review findings from Correctness review (head 2acf6cb)
|
- Build on the merged hivecommons#18521 backend and expose its identity and provenance in Settings. - Serialize setting changes with reference-repo re-resolution. Co-authored-by: Andy Anderson <andy@clubanderson.com> Signed-off-by: Andy Anderson <andy@clubanderson.com> Signed-off-by: hivecommons-hive[bot] <280983584+hivecommons-hive[bot]@users.noreply.github.com>
- Build on the merged hivecommons#18521 backend and expose identity and provenance in Settings. - Serialize setting changes with reference-repo re-resolution. Co-authored-by: Andy Anderson <andy@clubanderson.com> Signed-off-by: Andy Anderson <andy@clubanderson.com> Signed-off-by: Karibhou <157208370+Karibhou@users.noreply.github.com>
Part 1 of #18516 (follow-up to #18196). This PR covers the backend: identity resolution, the App mint, the proxy credential for each policy, and the kick text. The Settings control, the API and the docs come in a second PR.
What it does
The new key
project.remote_write_identitysets whose name appears on the issues, PRs and comments a hive posts on a granted write-tier reference repo:bot(default; a missing key reads as this)hivecommons-hive[bot]bot_onlyhivecommons-hive[bot]ownerGET /repos/{owner}/{repo}/installationwith the App JWT, so an install limited to selected repos is respected. Results are cached like the org discovery. Nothing asks a project to install the App. The read-only notice names no cure underbot_only.credential_state: unresolved, with no request-issue notice). The hive does not silently switch to the owner's name.write_token_filestill wins on hand-written entries.[bot]login never names a fork, so bot PR branches are pushed to the reference repo itself, under the same default-branch guard. An App cannot own a fork.--head <branch>") next to the owner's fork flow.creator=<owner>. Follow-up on bot-authored items will be tracked separately.How existing hives behave after upgrade
No hive has the key yet, so every hive reads as
bot.hivecommons-hive[bot]instead of the owner. This is the intended change. Example: the hivecommons repos derived from [Assessment request]: Hive Commons (pilot of the AI-assisted assessment workflow) cncf/techdocs#395 now post as the bot without the owner connecting an account.Owners who want today's behaviour can set
owner. That control lands in part 2.Tests
pkg/github/reference_repo_identity_test.go: the full matrix of setting (""/bot/bot_only/owner) × App installed × owner connected. Also: bot_only never resolves to the owner, read-only entries get nothing under any setting, a transient failure never switches identity, the token file wins, the token source is cached and per repo, and an httptest check of the real mint (repository-level installation lookup,repositories: ["docs"], the exact permission set, never the hive's own installation).cmd/hive/reference_repos_identity_test.go: the pilot case, the no-grant-no-token invariant, bot_only never reading the owner token, the per-repo credential in a mixed set, and transient lookups staying read-only.crux/proxy/reference_repos_identity_test.go: the proxy injects each repo's own credential on each call, read-only repos get nothing, a bot push goes to the repo under the default-branch guard, management is refused under both identities, and a bot login never names a fork.The settings-parity allowlist gets
project.remote_write_identityuntil part 2 adds the control.Refs #18516
🤖 Generated with Claude Code