Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/changed-6326-dead-spoke-aliases.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Delete the production-dead `pkg/hub` spoke alias layer and the byte-identical duplicate hub test copies; hub tests now call `pkg/hub/spoke` directly (#6326).
2 changes: 1 addition & 1 deletion src/cmd/hive/agent_activity_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"github.com/hivecommons/hive/pkg/agent"
"github.com/hivecommons/hive/pkg/config"
"github.com/hivecommons/hive/pkg/governor"
"github.com/hivecommons/hive/pkg/hub"
hub "github.com/hivecommons/hive/pkg/hub/spoke"
)

// activityTestConfig builds the minimal config agentActivityFor needs: one
Expand Down
2 changes: 1 addition & 1 deletion src/cmd/hive/config_overrides_replay_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"github.com/hivecommons/hive/pkg/config"
"github.com/hivecommons/hive/pkg/dashboard"
"github.com/hivecommons/hive/pkg/github"
"github.com/hivecommons/hive/pkg/hub"
hub "github.com/hivecommons/hive/pkg/hub/spoke"
"github.com/hivecommons/hive/pkg/snapshot"
)

Expand Down
2 changes: 1 addition & 1 deletion src/cmd/hive/heartbeat_idle_cadence_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"github.com/hivecommons/hive/pkg/agent"
"github.com/hivecommons/hive/pkg/config"
"github.com/hivecommons/hive/pkg/governor"
"github.com/hivecommons/hive/pkg/hub"
hub "github.com/hivecommons/hive/pkg/hub/spoke"
)

func TestHeartbeatKickIntervalOnlyForGovernorKickedAgents(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion src/cmd/hive/provider_budget_probe_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"github.com/hivecommons/hive/pkg/config"
"github.com/hivecommons/hive/pkg/dashboard"
"github.com/hivecommons/hive/pkg/governor"
"github.com/hivecommons/hive/pkg/hub"
hub "github.com/hivecommons/hive/pkg/hub/spoke"
)

// TestProviderBudgetSuppressionProbesRatherThanDeadlocks is the regression test
Expand Down
2 changes: 1 addition & 1 deletion src/cmd/hive/quota_exhausted_agents_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package main
import (
"testing"

"github.com/hivecommons/hive/pkg/hub"
hub "github.com/hivecommons/hive/pkg/hub/spoke"
)

// quotaExhaustedAgentCount must count ONLY running, unpaused agents whose
Expand Down
148 changes: 0 additions & 148 deletions src/pkg/hub/heartbeat_activity_test.go

This file was deleted.

4 changes: 3 additions & 1 deletion src/pkg/hub/hub_keys_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ package hub

import (
"testing"

"github.com/hivecommons/hive/pkg/hub/spoke"
"time"
)

Expand Down Expand Up @@ -61,7 +63,7 @@ func TestSpokeHeartbeatKeyCannotForgeOtherDomains(t *testing.T) {
// asymmetric: the spoke holds only the public key and no signing seed at all,
// so this also stands in for "spoke has no private material to sign with".)
forgedSSO := MintSSOToken(spokeHeartbeatKey, "victim-owner", "owner", "hive-x", now)
if _, _, err := VerifySSOToken(ssoPubKey, forgedSSO, "hive-x", now); err == nil {
if _, _, err := spoke.VerifySSOToken(ssoPubKey, forgedSSO, "hive-x", now); err == nil {
t.Error("spoke heartbeat key forged a valid SSO handoff token")
}

Expand Down
4 changes: 3 additions & 1 deletion src/pkg/hub/hub_pubkey_generations.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import (
"os"
"strings"
"time"

"github.com/hivecommons/hive/pkg/hub/spoke"
)

// SSO / SESSION Ed25519 PUBLIC KEY plurality — follow-on PR #6 of the
Expand Down Expand Up @@ -362,7 +364,7 @@ func VerifySSOTokenAcrossKeys(keys []string, token, expectedHiveID string, now t
matchedIndex := -1
var matchedUser, matchedRole string
for i, k := range valid {
u, r, verr := VerifySSOToken(k, token, expectedHiveID, now)
u, r, verr := spoke.VerifySSOToken(k, token, expectedHiveID, now)
// Recorded unconditionally, and the loop deliberately continues. See the
// TIMING note above: an early return here would make the spoke's
// convergence state observable as latency.
Expand Down
4 changes: 3 additions & 1 deletion src/pkg/hub/image_tag_validation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import (
"path/filepath"
"strings"
"testing"

"github.com/hivecommons/hive/pkg/hub/spoke"
)

func TestValidateImageTagRefusesMalformed(t *testing.T) {
Expand Down Expand Up @@ -177,7 +179,7 @@ func TestSwitchImageSelfRefusesBogusTag(t *testing.T) {
"ghcr.io/hivecommons/hive:",
"",
} {
err := SwitchImageSelf(slog.Default(), image)
err := spoke.SwitchImageSelf(slog.Default(), image)
if err == nil {
t.Errorf("SwitchImageSelf(%q) = nil, want refusal", image)
continue
Expand Down
16 changes: 9 additions & 7 deletions src/pkg/hub/small_gaps_coverage_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import (
"net/http/httptest"
"strings"
"testing"

"github.com/hivecommons/hive/pkg/hub/spoke"
"time"
)

Expand Down Expand Up @@ -102,31 +104,31 @@ func TestVerifySSOTokenBranches(t *testing.T) {
}

// Wrong key -> bad signature.
if _, _, err := VerifySSOToken(otherPub, tok, "hiveA", now); err == nil {
if _, _, err := spoke.VerifySSOToken(otherPub, tok, "hiveA", now); err == nil {
t.Error("expected bad signature with the wrong public key")
}
// Empty key -> no verification key error.
if _, _, err := VerifySSOToken("", tok, "hiveA", now); err == nil {
if _, _, err := spoke.VerifySSOToken("", tok, "hiveA", now); err == nil {
t.Error("expected error with empty public key")
}
// Malformed token.
if _, _, err := VerifySSOToken(pub, "no-dot", "hiveA", now); err == nil {
if _, _, err := spoke.VerifySSOToken(pub, "no-dot", "hiveA", now); err == nil {
t.Error("expected malformed token error")
}
// Wrong hive.
if _, _, err := VerifySSOToken(pub, tok, "hiveB", now); err == nil {
if _, _, err := spoke.VerifySSOToken(pub, tok, "hiveB", now); err == nil {
t.Error("expected wrong-hive error")
}
// Expired.
if _, _, err := VerifySSOToken(pub, tok, "hiveA", now.Add(10*time.Minute)); err == nil {
if _, _, err := spoke.VerifySSOToken(pub, tok, "hiveA", now.Add(10*time.Minute)); err == nil {
t.Error("expected expired error")
}
// Not yet valid.
if _, _, err := VerifySSOToken(pub, tok, "hiveA", now.Add(-10*time.Minute)); err == nil {
if _, _, err := spoke.VerifySSOToken(pub, tok, "hiveA", now.Add(-10*time.Minute)); err == nil {
t.Error("expected not-yet-valid error")
}
// Valid round trip.
u, role, err := VerifySSOToken(pub, tok, "hiveA", now)
u, role, err := spoke.VerifySSOToken(pub, tok, "hiveA", now)
if err != nil || u != "alice" || role != "owner" {
t.Errorf("valid verify failed: u=%q role=%q err=%v", u, role, err)
}
Expand Down
82 changes: 10 additions & 72 deletions src/pkg/hub/spoke_deleted_aliases.go
Original file line number Diff line number Diff line change
@@ -1,89 +1,27 @@
package hub

import (
"encoding/json"
"log/slog"
"time"

"github.com/hivecommons/hive/pkg/agent"
"github.com/hivecommons/hive/pkg/config"
"github.com/hivecommons/hive/pkg/governor"

"github.com/hivecommons/hive/pkg/hub/spoke"
)

type InferenceBudgetProvider = spoke.InferenceBudgetProvider
"time"
)

func CollectClusterHealth(logger *slog.Logger) *HeartbeatClusterHealthReport {
report := spoke.CollectClusterHealth(logger)
if report == nil {
return nil
}
var out HeartbeatClusterHealthReport
data, err := json.Marshal(report)
if err != nil {
return nil
}
if err := json.Unmarshal(data, &out); err != nil {
return nil
}
return &out
}
func OpenFDCount() int { return spoke.OpenFDCount() }
func FDSoftLimit() uint64 { return spoke.FDSoftLimit() }
// This file holds the surviving pass-through aliases from the spoke
// extraction (#6068). Only aliases with live production callers remain;
// new code should import pkg/hub/spoke directly (as pkg/dashboard already
// does) instead of adding aliases here.

func AgentActivityFor(mgr *agent.Manager, cfg *config.Config, govState governor.State, currentMode, name string, proc *agent.AgentProcess, onDemandFromPack map[string]bool) AgentActivity {
act := spoke.AgentActivityFor(mgr, cfg, govState, currentMode, name, proc, onDemandFromPack)
var out AgentActivity
data, err := json.Marshal(act)
if err != nil {
return out
}
_ = json.Unmarshal(data, &out)
return out
}
func HeartbeatKickInterval(govState governor.State, name string, proc *agent.AgentProcess, onDemandFromPack map[string]bool) time.Duration {
return spoke.HeartbeatKickInterval(govState, name, proc, onDemandFromPack)
}
func spokeAgentSummaries(agents []AgentSummary) []spoke.AgentSummary {
var out []spoke.AgentSummary
data, err := json.Marshal(agents)
if err != nil {
return nil
}
_ = json.Unmarshal(data, &out)
return out
}
func QuotaExhaustedAgentCount(agents []AgentSummary) int {
return spoke.QuotaExhaustedAgentCount(spokeAgentSummaries(agents))
}
func QuotaExhaustedProcessCount(statuses map[string]*agent.AgentProcess) int {
return spoke.QuotaExhaustedProcessCount(statuses)
}
func QuotaExhaustedAgentReason(count int) string { return spoke.QuotaExhaustedAgentReason(count) }
func ProviderLimitHeartbeatFields(agents []AgentSummary, budget InferenceBudgetProvider) (string, int, bool, []string) {
return spoke.ProviderLimitHeartbeatFields(spokeAgentSummaries(agents), budget)
}
func HashDashboardToken(token string) string { return spoke.HashDashboardToken(token) }
func RolloutRestartSelf(logger *slog.Logger) error { return spoke.RolloutRestartSelf(logger) }
func SwitchImageSelf(logger *slog.Logger, image string) error {
return spoke.SwitchImageSelf(logger, image)
}
func UpgradeSelfToSHA(logger *slog.Logger, targetSHA string) (bool, error) {
return spoke.UpgradeSelfToSHA(logger, targetSHA)
}

func HashDashboardToken(token string) string { return spoke.HashDashboardToken(token) }

func SelfImageReleaseChannel() string { return spoke.SelfImageReleaseChannel() }
func SelfDeploymentImage() string { return spoke.SelfDeploymentImage() }

func MintSSOToken(seedHex, username, role, hiveID string, now time.Time) string {
return spoke.MintSSOToken(seedHex, username, role, hiveID, now)
}
func VerifySSOToken(pubHex, token, expectedHiveID string, now time.Time) (string, string, error) {
return spoke.VerifySSOToken(pubHex, token, expectedHiveID, now)
}
func TerminalSigningKey() string { return spoke.TerminalSigningKey() }
func MintTerminalAssertion(key, username, role, hiveID string, now time.Time) string {
return spoke.MintTerminalAssertion(key, username, role, hiveID, now)
}
func VerifyTerminalAssertion(key, token, expectedHiveID string, now time.Time) (string, string, error) {
return spoke.VerifyTerminalAssertion(key, token, expectedHiveID, now)
}
Loading
Loading