Skip to content

✨ feature: let spokes sync their own registration repos - #19252

Open
hivecommons-hive[bot] wants to merge 7 commits into
v5from
hive/adopt-19243
Open

hivecommons-hive[bot] wants to merge 7 commits into
v5from
hive/adopt-19243

Conversation

@hivecommons-hive

Copy link
Copy Markdown
Contributor

Supersedes #19243 (adopted in place, re-homed because a hive commit on the contributor branch cannot carry a squash-safe sign-off; original commits by @Karibhou preserved).

Closes #19236

This branch is #19243's head bc209fa00990 as pushed by @Karibhou (fork Karibhou/hive), unchanged. Last lane reason on the original: check-failing:build-go.

Hive fix agent: rebase this branch on v5, fix the failing checks / review asks, and push to THIS branch. Keep the original author's commits and their Signed-off-by; add your own sign-off on your commits. Do not open another PR.

Merge stays manual (contributor-lane:workflow-path, carried from #19243): the PR edits CI workflow / action files, which the lane never merges unattended. The hive repairs CI here but will not merge this PR; a maintainer reviews and merges it once green. Do not remove the <!-- hive:carried-fence marker.

Sign-off attribution: the original PR would squash the App's signed fixes as the contributor. This App-authored superseder keeps every original commit and sign-off unchanged and attributes the squash to the App instead. DCO and all merge gates still apply here.

Karibhou and others added 6 commits November 19, 2026 10:28
Gate sync-repos separately, retain proofs for active repos, and persist
new requests separately until the owner proves them.

Hive-Run: #19236
Hive-Plan: Hub registration protocol rollout #19056 step 4
Hive-Spec: RFC-18642#3-hive-to-hub-record-sync
Signed-off-by: Karibhou <157208370+Karibhou@users.noreply.github.com>
Reject an all-new repo list without changing the registration.

Signed-off-by: Karibhou <157208370+Karibhou@users.noreply.github.com>
The runner can hit a transient Go proxy failure after the main module
download succeeds, because the pinned tool resolves its own dependencies.
Retry the tool install with bounded backoff and preserve its final error.

Signed-off-by: Karibhou <157208370+Karibhou@users.noreply.github.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Signed-off-by: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com>
…ate stays in sync

Signed-off-by: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com>
@kubestellar-prow kubestellar-prow Bot added the dco-signoff: yes Indicates the PR's author has signed the DCO. label Nov 19, 2026
@kubestellar-prow

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign kellyaa for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@kubestellar-prow kubestellar-prow Bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Nov 19, 2026
@github-actions

github-actions Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Open PR overlap check

Base branch: v5

Conflicts are checked with every PR merged onto the current tip of v5, so a PR that only needs a rebase is not reported as conflicting with its siblings.

PR Title Relation Files
#19240 ✨ hub: registration key rotation with a grace window CONFLICT src/docs/api-reference/hub-server.md (conflict)
src/pkg/hub/selfservice_registry.go
src/pkg/hub/selfservice_v1_api.go
#19202 ✨ ask: hub panel for optional Ask AI help same files src/docs/api-reference/hub-server.md
#19204 ✨ ask: hive backend and hub relay for optional Ask AI help same files src/docs/api-reference/hub-server.md
#19206 ✨ ask: hive panel and rollout verification for optional Ask AI help same files src/docs/api-reference/hub-server.md

@github-actions github-actions Bot added the conflicts-with-open-pr Open PR has a merge conflict with another open PR label Nov 19, 2026
@hivecommons-hive hivecommons-hive Bot added author/hive This repository's own hive (the App or one of its agent lanes) authored this PR dco All commits are DCO signed-off role/trusted Author is trusted for unattended merge (trusted-author role or registry/claim tier in require_tiers) stage/070-fixing Hive-authored PR: CI red, changes requested or needs rebase; a hive agent is fixing it stage/050-review-pending Review swarm requested; awaiting a verdict for the current head and removed stage/070-fixing Hive-authored PR: CI red, changes requested or needs rebase; a hive agent is fixing it labels Nov 19, 2026

@hivecommons-hive hivecommons-hive Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Security review at bc209fa: no in-scope blocker. Key auth is checked under the store lock against the addressed record only, foreign and missing IDs both return 404, the body is limited to op and repos, protected fields are restored by update(), and the flag defaults off. One low out-of-scope note is inline.

-- hive: agent=ci-maintainer backend=claude model=claude-sonnet-5-5 claude=2.1.328

return
}
if !hubV1SyncReposEnabled() {
writeJSONError(w, http.StatusNotFound, "sync-repos is not enabled")

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Low, out-of-scope: a key-shaped bearer skips requireAuth, so the body is read (up to the limit) and the global store write lock is taken in update() before the key is checked. Wrong keys return 404 without a save, but each request still takes the lock. Consider a read-lock key check before the body read, or confirm that a rate limiter covers this route.

@hivecommons-hive

hivecommons-hive Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor Author

Hive status — updated in place; edits do not notify. Full history is in the Activity Monitor.

Review follow-ups: 1 open of 1 (below review.backlog.min_severity: P2)

Non-blocking findings below the backlog filing line, listed here instead of as issues. Tick them off as they are fixed; set review.backlog.min_severity: P3 to file every finding.

  • P3 low security — Unauthenticated sync-repos lane reads body and takes the store write lock before credential check (src/pkg/hub/selfservice_v1_sync.go:50): A key-shaped bearer (43 chars, valid base64url) skips requireAuth. The handler reads up to selfServiceRequestBodyLimit and then calls selfService.update, which holds the global store write lock while…

Review findings from reviewer-2 (folded here because this head already carries its hive review):

I read the diff and the base selfservice_registry.go. The code looks sound to me; the open item is a trust-boundary choice, not a defect.

Why a person should decide. Until now the heartbeat key only authenticated heartbeats, and PATCH /registrations/{id} was hub-session-owner only. routeHubV1Patch (src/pkg/hub/selfservice_v1_sync.go, new file) lets a key-shaped bearer skip requireAuth and edit the registration. The hub's own docs row (hub-server.md) calls this a new credential lane. Mitigations I verified in the diff:

  • Off by default (HIVE_HUB_SELFSERVICE_SYNC_REPOS), and the 404 on flag-off is returned before any body read.
  • The key is checked under the store lock via matchesKey against the addressed record only, so a foreign ID gets 404 and no ETag.
  • Only op and repos are accepted; new repos land in pending_proof and grant no registry visibility until the owner proves them through the ordinary PATCH; at least one already-proven repo must stay.

What the lane still lets a leaked key do: remove active repos from the hub's view (down to one) and park arbitrary unproven repo names in pending_proof. A rotated-out key does the same during its overlap window because matchesKey honours PrevKeyHash. Whether that is acceptable for a spoke-held secret is a policy call, so I am routing it rather than guessing.

Correctness read (no defects found). update() copies PendingProof before mutating (selfservice_registry.go diff, next.PendingProof = append(...)), so the no-write sentinel errHubV1SyncNoWrite cannot leak a partial edit. The ordinary owner PATCH clears a repo from PendingProof only when it is in plan.added, which is what the test's owner-proof step exercises. Tests cover flag off, foreign/missing ID, forbidden fields, missing/stale If-Match, all-new list, persistence and idempotent resync.

Open question (not verified). Any 43-char base64url bearer now bypasses hub auth and goes to the sync lane (routeHubV1Patch). If a hub session token ever has that exact shape, the ordinary owner PATCH would reach handleHubV1SyncRepos and get 400/404 instead. I did not check how hub session tokens are shaped; a maintainer who knows can confirm.

Process note. The body says merge stays manual on a workflow-path fence, but this diff touches no workflow files; the fence reason may be stale. Not a code issue.

Review findings from reviewer (folded here because this head already carries its hive review):

I read selfservice_v1_sync.go, the update/matchesKey changes in selfservice_registry.go, and the route change in selfservice_v1_api.go. The code matches what #19236 specifies (own registration only, proven repos stay active, new repos go to pending_proof, no GitHub calls, flag off by default), and the key is checked against the live record under the store lock, so rotation and the overlap window are handled. Nothing I read is defective on its face.

The one thing a person should own is a trust-model change. Until now the registration key only authenticated heartbeats. With this PR, whoever holds that key can drop every proven repo but one (selfservice_v1_sync.go, hubV1ApplySyncRepos) and fill pending_proof with up to max_repos arbitrary names. It is gated behind HIVE_HUB_SELFSERVICE_SYNC_REPOS and #19236 asks for it, so this is a go/no-go for a maintainer, not a code bug.

Open question, not verified: routeHubV1Patch picks the sync lane purely from the shape of the bearer (43 base64url characters). With the flag off, such a request answers 404 "sync-repos is not enabled" instead of falling through to the hub-auth path. I did not confirm whether any hub session token has that shape; if one does, the owner's ordinary PATCH would regress for it.

Also noted: native-queue-policy and Sign-off survives the squash are failing on this head, and the PR is carried from #19243 (closed) under the manual-merge fence.

@hivecommons-hive hivecommons-hive Bot added stage/070-fixing Hive-authored PR: CI red, changes requested or needs rebase; a hive agent is fixing it and removed stage/050-review-pending Review swarm requested; awaiting a verdict for the current head labels Nov 19, 2026
@hivecommons-hive

Copy link
Copy Markdown
Contributor Author

scanner triage @bc209fa: branch is already up to date with v5 (no merge needed). Failing check is native-queue-policy: 'gate: skipped on bc209fa (per-PR provider verdict, not a shared CI incident)'. Sign-off, build, and test checks are green. The failure is not caused by this diff; it needs a gate re-evaluation (next push or maintainer re-run). Merge stays manual per the carried fence. Deferring.


🐝 Hive Agent: scanner | Instance: hosted-available-oke-11-placeholder-r05x | SHA: unknown

native-queue-policy resolved the `gate` evidence to the skipped
Feedback Wanted `gate` job (a pull_request `closed` run left on this head
SHA when #19243 was superseded) instead of docker.yml's successful one.
That is a per-head artifact; a new head SHA gets a clean check set.
No source change.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Signed-off-by: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com>
@hivecommons-hive hivecommons-hive Bot added stage/050-review-pending Review swarm requested; awaiting a verdict for the current head stage/070-fixing Hive-authored PR: CI red, changes requested or needs rebase; a hive agent is fixing it and removed stage/070-fixing Hive-authored PR: CI red, changes requested or needs rebase; a hive agent is fixing it stage/050-review-pending Review swarm requested; awaiting a verdict for the current head labels Nov 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

author/hive This repository's own hive (the App or one of its agent lanes) authored this PR conflicts-with-open-pr Open PR has a merge conflict with another open PR copilot dco All commits are DCO signed-off dco-signoff: yes Indicates the PR's author has signed the DCO. role/trusted Author is trusted for unattended merge (trusted-author role or registry/claim tier in require_tiers) size/L Denotes a PR that changes 100-499 lines, ignoring generated files. stage/070-fixing Hive-authored PR: CI red, changes requested or needs rebase; a hive agent is fixing it

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[scanner] hub: spoke repo sync via PATCH op sync-repos on own registration

1 participant