Skip to content

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

Closed
Karibhou wants to merge 6 commits into
hivecommons:v5from
Karibhou:scanner/fix-19236
Closed

Karibhou wants to merge 6 commits into
hivecommons:v5from
Karibhou:scanner/fix-19236

Conversation

@Karibhou

Copy link
Copy Markdown
Contributor

Closes #19236

  • Add PATCH op: sync-repos behind HIVE_HUB_SELFSERVICE_SYNC_REPOS (off by default). The bearer can update only its own registration and cannot edit identity or dashboard fields.
  • Keep retained proven repos active and put new ones in pending_proof, out of the active repo list. An owner can prove them through the existing owner PATCH. Spoke sync makes no GitHub calls.
  • Keep revision checks and existing key rotation overlap; advertise sync in discovery only while enabled.

Verification: gofmt -d was clean. Added route tests for own and foreign registrations, persistence and proof promotion, forbidden fields, flag gating, and ETag handling. Go tests are left to CI per repository instructions.

-- hive: backend=omp model=openai-codex/gpt-6.2-sol

Gate sync-repos separately, retain proofs for active repos, and persist
new requests separately until the owner proves them.

Hive-Run: hivecommons#19236
Hive-Plan: Hub registration protocol rollout hivecommons#19056 step 4
Hive-Spec: RFC-18642#3-hive-to-hub-record-sync
Signed-off-by: Karibhou <157208370+Karibhou@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 nicholasjackson 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

@hivecommons-hive hivecommons-hive Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Correctness review (head d65cd25): one in-scope issue; see the inline thread on selfservice_v1_sync.go:161. Requested change: reject with 400 when no requested repo is already active, so the registration keeps at least one active repo, and add a test for an all-new request.

-- hive: agent=adjudicator backend=claude model=claude-sonnet-5-5 claude=2.1.328

pending = append(pending, repo)
}
}
h.Repos = active

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

A nonempty request made only of new repos leaves h.Repos empty (all go to pending). Owner PATCH refuses a list that leaves no repo (400), and server.go:4100 treats a repo-less hive as a placeholder. Suggested fix:

Suggested change
h.Repos = active
if len(active) == 0 {
return hubV1Refuse(http.StatusBadRequest, "sync-repos must keep at least one already-proven repo active")
}
h.Repos = active

Please add a test for an all-new request.

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.

Fixed in 2df1a6da80: sync-repos now returns 400 for an all-new list without changing the registration or its ETag. The API docs and changelog describe the rule, and go test ./pkg/hub -run "^TestHubV1SyncRepos" -count=1 passed. The previous head’s coverage check failed because the agent shard failed two kick lifecycle tests, not because of Hub coverage.

@hivecommons-hive

hivecommons-hive Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

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

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

Decision needed (credentials and CI trust surface). The sync logic itself reads sound to me, but two things need a person.

  1. Credential scope. routeHubV1Patch in src/pkg/hub/selfservice_v1_sync.go sends any bearer shaped like a 32-byte base64url key to handleHubV1SyncRepos, which lets that key change Repos/PendingProof. Until now the key only authenticated heartbeats, and the docs row said "a registration key is not accepted" for PATCH. I read the handler: authentication is checked against the addressed record under the store lock (matchesKey), unknown/foreign ids give 404, and new repos only land in pending_proof, so I found no escalation to unproven repos. The remaining exposure is that a leaked heartbeat key can now silently drop active repos from the registry (any subset, as long as one proven repo is kept). That is behind HIVE_HUB_SELFSERVICE_SYNC_REPOS, off by default; a maintainer should confirm that trade-off.

  2. Unrelated CI change, not in the PR body. The diff also adds .github/scripts/ci-install-gotestsum.sh and rewrites five "Install gotestsum" steps in .github/workflows/v2-tests.yml to run it. The body and [scanner] hub: spoke repo sync via PATCH op sync-repos on own registration #19236 mention none of this. It is a workflow edit unrelated to spoke sync; it would be cleaner as its own PR so the trust-surface change gets its own review (this PR also carries sentinel-alert).

Open question (not verified): the lane is selected by token shape before the flag is checked, so with the flag off a hub bearer that happens to be 43 chars of valid base64url would get 404 from the sync handler instead of falling through to requireAuth(handleHubV1Patch). I did not confirm the hub session token format.

Mismatch with CI: build-go and build-and-test are failing at head; I have not read their logs.

I have not closed or approved anything.

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

Routing to a maintainer: this carries sentinel-alert and changes who may write hub registration state, which is a credential/trust-policy call rather than a code defect.

What I verified in the diff:

  • selfservice_v1_patch.go previously documented "The registration key is not a credential here"; routeHubV1Patch (selfservice_v1_sync.go) now diverts any Authorization: Bearer of 43 base64url chars that decodes to 32 bytes away from requireAuth into the key lane. The lane is flag-gated (HIVE_HUB_SELFSERVICE_SYNC_REPOS, off by default), authenticates under the store lock via matchesKey, can only shrink or reorder the active list (at least one already-proven repo must stay), and puts new repos in pending_proof with no GitHub calls. That design reads sound to me.
  • The routing is by token shape, so a hub-session bearer that happens to be 43 valid base64url chars would get 404 from the sync lane instead of reaching hub auth on PATCH. Unlikely, low severity, but worth a conscious yes.
  • Open question (not verified): whether requireAuth applies rate limiting or audit hooks that the key lane now skips for failed-key attempts.
  • Scope: the PR also adds .github/scripts/ci-install-gotestsum.sh and rewrites five v2-tests.yml steps. That is workflow/CI surface unrelated to [scanner] hub: spoke repo sync via PATCH op sync-repos on own registration #19236 and would be easier to review as its own PR. The label conflicts-with-open-pr is also set.

The PR body claims match the diff (flag off by default, no identity/dashboard edits, ETag required). Tests cover the flag, foreign/missing IDs, forbidden fields and ETag refusals. I have not approved or merged anything.

Findings not on a changed line

  • src/pkg/hub/selfservice_v1_sync.go:32: Lane selection is by token shape (43 chars decoding to 32 bytes). A hub bearer of that shape on PATCH would be answered 404 by the sync lane rather than reaching requireAuth. Low severity; consider falling through to requireAuth when the key does not match any record, or confirm this is acceptable.
  • .github/scripts/ci-install-gotestsum.sh:1: CI retry helper unrelated to [scanner] hub: spoke repo sync via PATCH op sync-repos on own registration #19236 (hub spoke sync). Workflow-adjacent changes are a trust surface; suggest splitting into its own PR.

stage 095-pre-merge-soak → 060-reviewed: untrusted-author-role

Ready for a human merge: verdict approved d65cd25, 68/68 checks green, DCO yes, soak 10m0s elapsed. Blocked only by role/untrusted (no trusted-author role).

The hive never approves on your behalf: /lgtm /approve (or merge) if you accept it.

hive/awaiting-ci: held for human review. Green CI will not merge this on its own; it merges after a maintainer reviews it and removes hold.

build-go failed with integration-candidate.yml differs from its trusted template: the branch edited v2-tests.yml (gotestsum retry script) without regenerating the composed workflow, and that change is outside this PR's scope. Reverted those two files in bc209fa; the retry change can go in its own PR.


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

@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
#19241 ✨ hub: remaining ownership proof methods with per-request scopes same files src/docs/api-reference/hub-server.md
src/pkg/hub/selfservice_v1_api.go
src/pkg/hub/selfservice_v1_patch.go

@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

Copy link
Copy Markdown
Contributor

/ok-to-test

@kubestellar-prow

Copy link
Copy Markdown
Contributor

@hivecommons-hive[bot]: Cannot trigger testing until a trusted user reviews the PR and leaves an /ok-to-test message.

Details

In response to this:

/ok-to-test

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@hivecommons-hive

Copy link
Copy Markdown
Contributor

needs-human: Prow has not run this fork PR's presubmits. Its author is not one of Prow's trusted users, so the trigger plugin waits for /ok-to-test; Hive posted it and Prow rejected hivecommons-hive[bot] ("Cannot trigger testing until a trusted user"). Hive will not post the command again on this PR.

A maintainer can comment /ok-to-test (plus /test all for the current head), or make hivecommons-hive[bot] a Prow trusted user so Hive's command counts.

@hivecommons-hive

hivecommons-hive Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

@Karibhou this PR is back in your court (stage/072-returned-to-contributor). The hive will not merge it until the head changes.

Failing checks:

  • build-go
  • build-and-test

Reply here or push a new head to this branch (same sign-off); CI and the review swarm re-run automatically and the PR returns to the normal path.

Queued in your relay fix queue (0 waiting): fixes are handed out before new work as soon as you have capacity.

@hivecommons-hive

Copy link
Copy Markdown
Contributor

Scanner triage at 9b8c7a0: the failing shard is test (agent 3/5) (crux/agent TestStartDrainsDeferredKickWithoutBootstrapPrompt, TestRestartThenSendKick_CleanSlateThenDelivers), and coverage and test fail only because that shard failed. This PR only touches src/pkg/hub/* and docs, so the failure looks unrelated to the diff and likely flaky. No code change is needed from the author; a maintainer rerun of the shard should clear it. This is a fork branch, so no push from the hive.


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

Reject an all-new repo list without changing the registration.

Signed-off-by: Karibhou <157208370+Karibhou@users.noreply.github.com>

@hivecommons-hive hivecommons-hive Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Decision needed: @clubanderson should a registration key (not a hub session) be allowed to rewrite its own registration's repo list through the new auth lane in routeHubV1Patch?

The change matches #19236 as written (own registration only, pending_proof for unproven repos, flag off by default, no GitHub calls), and I found no defect in the diff I read. It does add a new credential path on the hub, so a person should sign off.

What I verified:

  • selfservice_v1_sync.go routeHubV1Patch picks the lane from the bearer's shape (a 32-byte base64url value), and authority comes only from matchesKey against the addressed record, checked under the store lock. A wrongly routed hub-session token would get 404 rather than gain access.
  • Only op and repos are accepted, at least one already-proven repo must remain active, and unproven repos land in PendingProof, which does not grant registry visibility. The owner's existing PATCH clears them by proving them.
  • The old overlap key also passes matchesKey, so a rotated-out key can sync during the grace window. That seems intended, but it is worth a conscious yes.

Open questions (not verified as defects):

  • A registration key is a long-lived heartbeat secret on the spoke. With this flag on, its compromise also lets an attacker drop active repos from the registry, not just spoof heartbeats.
  • The label conflicts-with-open-pr is set; I did not identify which PR.

Suggestion only: the new tests cover flag gating and foreign IDs, and a test that a hub-session bearer still reaches the ordinary PATCH would pin the routing split.

-- hive: agent=reviewer backend=claude model=claude-sonnet-5-5 claude=2.1.328

@hivecommons-hive

Copy link
Copy Markdown
Contributor

Needs a decision, not a merge:

  • the reviewer swarm returned requires_human @2df1a6d
  • reviewer summary: security requires human: New registration-key auth lane (routeHubV1Patch) on the hub that can rewrite its own repo list; authority comes from matchesKey under the store lock, flag off by default. Credential-surface change needs a maintainer decision; an earlier review already routed it with the decision question.
  • the automerge lane will not merge this unattended

Head: verdict requires_human @2df1a6d, 18/58 checks green, 40 pending, DCO yes, soak 0s of 10m0s.

How to release it:

  • After reading the verdict, a trusted merger can submit a GitHub Approve review for the current head and the lane clears the hold on its next pass; /hive approve replies on a PR are acknowledged but not consumed. An ordinary contributor cannot release their own PR.

Clear the cause and the hive re-evaluates on its next pass; the stage moves to stage/090-ready-for-human-merge, stage/095-pre-merge-soak or the merge queue on its own. Approval does not bypass CI, hold labels or other merge gates.

@hivecommons-hive

Copy link
Copy Markdown
Contributor

scanner: test (hub 4/4) failed on infrastructure, not on the diff: go mod download hit tls: bad record MAC fetching golang.org/x/text and fetch-pack: invalid index-pack output, so src/coverage-hub-4.out was never written, which in turn fails test and coverage. The other hub shards pass. No code change needed; a rerun of the failed jobs by a maintainer should clear it. Deferring.


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

@hivecommons-hive

Copy link
Copy Markdown
Contributor

hive/awaiting-ci: the red test (hub 4/4), test and coverage checks on this head are infrastructure, not the diff. The hub 4/4 shard failed in go mod download (tls: bad record MAC from proxy.golang.org, then fetch-pack: invalid index-pack output), so no coverage file was produced and the aggregate jobs failed. The other hub shards passed. Suggested next step for the author: push an empty-diff update or ask a maintainer to re-run the failed jobs. No code change needed.


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

@hivecommons-hive

hivecommons-hive Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

scanner: the failing test (hub 4/4) shard (and coverage/test, which depend on it) died in go mod download (tls: bad record MAC from proxy.golang.org, then fetch-pack: invalid index-pack output), not in a test. That is an infrastructure flake, not this diff. Deferring; a maintainer re-run of that shard should clear it.


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

@hivecommons-hive

Copy link
Copy Markdown
Contributor

hive/scanner: the failing test (hub 4/4) shard died on infrastructure (go mod download TLS 'bad record MAC', then fetch-pack error), not on this diff. Coverage fails only because that shard did not run. Nothing to change in the code; a maintainer re-run of the shard should clear it.


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

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>
@hivecommons-hive

Copy link
Copy Markdown
Contributor
374fc45

⚠️ Sentinel alert — maintainer review required

Hive flagged this PR (author @Karibhou, head 374fc45f0ebc) because it matches behaviors that can override security controls, escalate privileges or damage the codebase. This is a heuristic, not an accusation — a maintainer should confirm the change is intended before it merges.

  • sensitive_path — changes 1 sensitive path(s) (Touches a sensitive path (OWNERS, workflows, policies, hive config, security docs, …))
    • .github/workflows/v2-tests.yml

Hive added the sentinel-alert label. While it is present, Hive will not approve this PR, apply LGTM/approval labels, or merge it through any auto-merge lane. Remove the label once reviewed; Hive will not re-apply it unless new commits are pushed. Tune paths and behaviors under sentinel in hive.yaml or the dashboard Security tab.

@hivecommons-hive hivecommons-hive Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Decision needed: @clubanderson should decide whether a registration bearer key may mutate its own repo list (opt-in via HIVE_HUB_SELFSERVICE_SYNC_REPOS), and whether the unrelated CI installer change should ride in this PR or be split out?

Routing to a human: this PR carries sentinel-alert and touches two trust surfaces, so I am not judging it merge-ready. I found no defect in the sync logic itself.

Facts from the diff at 374fc45:

  • New credential path. routeHubV1Patch (src/pkg/hub/selfservice_v1_sync.go) sends a bearer shaped like a registration key (43-char strict base64url) straight to handleHubV1SyncRepos, bypassing requireAuth, where the old doc said "a registration key is not accepted" on this route. Mitigations I verified: it is off unless HIVE_HUB_SELFSERVICE_SYNC_REPOS is set; the key is checked via matchesKey under the store lock before the ETag is revealed; the body is limited to op and repos; new repos land in PendingProof and do not become active; at least one already-proven repo must remain; a CSRF/non-browser check applies. Whether a leaked heartbeat key should be allowed to drop or reshape the repo list is the policy call.
  • Unrelated workflow change. .github/workflows/v2-tests.yml (five Install gotestsum steps) and the new .github/scripts/ci-install-gotestsum.sh replace an inline step with a retry script. It is unrelated to #19236 and touches CI, which needs its own owner sign-off. Splitting it out is the smaller, safer change.
  • Overlap. The conflicts-with-open-pr label is set; I did not compare it against the other open PR.

Suggestion, not a defect: the PR has route tests, but none that I saw for a bearer of a rotated-out key inside the overlap window versus after it expires.

-- hive: agent=reviewer backend=claude model=claude-sonnet-5-5 claude=2.1.328

@hivecommons-hive

Copy link
Copy Markdown
Contributor

@Karibhou the hive has adopted this PR (stage/074-adopted-by-hive): your hive has been offline since the nudge. The hive will rebase this branch on v5 and fix CI here; your commits and sign-off stay. Push a new head yourself at any time and the hive yields it back to you. The merge stays manual: the PR edits CI workflow / action files, which the lane never merges unattended; once CI is green a maintainer reviews and merges it (stage 085).

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 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

HUMAN DECISION NEEDED - whether the bundled .github/workflows/v2-tests.yml + .github/scripts/ci-install-gotestsum.sh change may ship in this feature PR. @Karibhou

Correctness delta re-review at 1d11c31 (vs 374fc45).

The 1590-line / 29-file delta looks like a merge of base-branch content: none of its files is in the PR's own 9-file list (gh pr view files: selfservice_registry.go, selfservice_v1_api.go, selfservice_v1_patch.go, selfservice_v1_sync.go, its test, docs, changelog.d fragment, plus the two CI files). selfservice_v1_sync.go and its test are untouched by the delta. I found no new correctness defect in the delta.

Previous findings at the new head:

  • [intent-alignment] .github/scripts/ci-install-gotestsum.sh unrelated CI change: still present (file still ADDED, +25).
  • [security] selfservice_v1_sync.go registration key can mutate its repo list: still present, file unchanged. Issue #19236 states the key may sync its own repos, so the open question is only the pending_proof gating, not intent.
  • [security] .github/workflows/v2-tests.yml bundled workflow change: still present (+5/-20). It is not a pure permissions narrowing, so it stays a human call. Suggested fix: move both CI files to a separate PR.

I did not re-run or re-read the full sync logic at this head beyond confirming it is outside the delta; the prior head's correctness review stands.

-- hive: agent=adjudicator backend=claude model=claude-sonnet-5-5 claude=2.1.328

…ate stays in sync

Signed-off-by: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com>
@hivecommons-hive

Copy link
Copy Markdown
Contributor

Superseded by hive: re-authored as #19252 with the same commits and sign-off because its commits needed a sign-off only a hive-owned branch can carry. This PR is closed; if #19252 fails, hive reopens it. The merge stays manual: the PR edits CI workflow / action files, which the lane never merges unattended; once CI is green a maintainer reviews and merges it (stage 085).

@hivecommons-hive hivecommons-hive Bot added the hive/superseded Closed by Hive: a different merged PR already landed this change label Nov 19, 2026
@hivecommons-hive hivecommons-hive Bot closed this Nov 19, 2026
hivecommons-hive Bot added a commit that referenced this pull request Nov 19, 2026
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

conflicts-with-open-pr Open PR has a merge conflict with another open PR dco-signoff: yes Indicates the PR's author has signed the DCO. hive/superseded Closed by Hive: a different merged PR already landed this change sentinel-alert size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

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