[architect] refactor: delete production-dead pkg/hub spoke alias layer and duplicate test copies - #6327
[architect] refactor: delete production-dead pkg/hub spoke alias layer and duplicate test copies#6327kubestellar-hive[bot] wants to merge 1 commit into
Conversation
…plicate hub test copies pkg/hub/spoke_deleted_aliases.go kept 15 aliases unreachable from any binary after the spoke extraction (#6068): production callers already import pkg/hub/spoke directly. Five had zero references anywhere (CollectClusterHealth, OpenFDCount, FDSoftLimit, RolloutRestartSelf, UpgradeSelfToSHA); the rest existed only to keep hub-side test copies compiling, several via lossy JSON round-trips between the duplicated hub/spoke struct types. - delete pkg/hub/sso_test.go and pkg/hub/heartbeat_activity_test.go: byte-identical duplicates of their pkg/hub/spoke twins - retarget remaining alias calls in hub_keys_test.go, image_tag_validation_test.go, small_gaps_coverage_test.go, sso_ed25519_coverage_test.go, terminal_key_per_hive_test.go to spoke.* - VerifySSOTokenAcrossKeys now calls spoke.VerifySSOToken directly - spoke_deleted_aliases.go keeps only the six live pass-throughs (QuotaExhaustedProcessCount/AgentReason, HashDashboardToken, SelfImageReleaseChannel, SelfDeploymentImage, MintSSOToken) No behavior change. go build ./... ok; go test ./pkg/hub ok. Refs #6326 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Signed-off-by: sec-check <sec-check@hive.kubestellar.io>
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
Hold-gate review: deletion is production-dead (verified), but the PR is red on errors it introduces. Not lifting
|
| Deleted symbol | Non-test callers of the pkg/hub alias |
Verdict |
|---|---|---|
InferenceBudgetProvider (type alias) |
none | dead |
CollectClusterHealth |
hubwire.go:899 only, via spoke-as-hub import |
dead |
OpenFDCount |
hubwire.go:758 only, via spoke-as-hub import |
dead |
FDSoftLimit |
hubwire.go:759 only, via spoke-as-hub import. heartbeat.go:210 is the struct FIELD FDSoftLimit uint64 \json:"fd_soft_limit"`` on the hub-side report type, which this PR does not touch, so the wire tag is unaffected |
dead |
AgentActivityFor |
hubwire.go:638,1182 only, via spoke-as-hub import |
dead in prod, LIVE in tests (see 3) |
HeartbeatKickInterval |
none | dead in prod, LIVE in tests (see 3) |
spokeAgentSummaries (unexported) |
none outside the alias file | dead |
QuotaExhaustedAgentCount |
none | dead in prod, LIVE in tests (see 3) |
ProviderLimitHeartbeatFields |
hubwire.go:699,1188 only, via spoke-as-hub import |
dead in prod, LIVE in tests (see 3) |
RolloutRestartSelf |
hubwire.go:999,1136 only, via spoke-as-hub import; other hits are comments |
dead |
SwitchImageSelf |
hubwire.go:402 only, via spoke-as-hub import |
dead |
UpgradeSelfToSHA |
hubwire.go:1128 only, via spoke-as-hub import |
dead |
VerifySSOToken |
hub_pubkey_generations.go:365 in-package, retargeted by this PR to spoke.VerifySSOToken |
dead after retarget |
TerminalSigningKey |
dashboard/session.go:251, terminal_handoff.go:61,115, all via spoke-as-hub import |
dead |
MintTerminalAssertion |
dashboard/session.go:262, via spoke-as-hub import |
dead |
VerifyTerminalAssertion |
terminal_handoff.go:115, via spoke-as-hub import |
dead |
Non-Go surfaces: no config keys, openapi fields, or dashboard JS reference any of these names. The only non-Go hits are comments in src/proxy/server.js and src/docs/design/master-key-rotation.md saying the JS mirrors hub.TerminalSigningKey / hub.VerifyTerminalAssertion; those describe the spoke implementation and stay accurate. None of the deleted items is a struct field, so no JSON tag is removed.
2. Duplicate tests
diff of pkg/hub/sso_test.go vs pkg/hub/spoke/sso_test.go and of pkg/hub/heartbeat_activity_test.go vs pkg/hub/spoke/heartbeat_activity_test.go: the only differing line in each is package hub vs package spoke. Same 7 + 5 test functions, same assertions. True duplicates.
3. Blocking: the PR breaks the cmd/hive test package
The retarget missed src/cmd/hive/, which imports the real pkg/hub (not the spoke alias) and calls the deleted functions:
src/cmd/hive/agent_activity_test.go:47,79,87,93,104,116:hub.AgentActivityForsrc/cmd/hive/heartbeat_idle_cadence_test.go:18,23,28:hub.HeartbeatKickIntervalsrc/cmd/hive/config_overrides_replay_test.go:169,190:hub.ProviderLimitHeartbeatFieldssrc/cmd/hive/provider_budget_probe_test.go:247:hub.ProviderLimitHeartbeatFieldssrc/cmd/hive/quota_exhausted_agents_test.go:23,31,34:hub.QuotaExhaustedAgentCount
Check-runs on 6427f1c: golangci-lint, test (rest 1/3), and build-and-test all fail with undefined: hub.AgentActivityFor / hub.ProviderLimitHeartbeatFields / hub.HeartbeatKickInterval (FAIL github.com/hivecommons/hive/cmd/hive [build failed]). The PR body's "go build ./... ok" is true because binaries compile; go vet / go test ./cmd/hive does not.
Also red: changelog-fragment-guard. changelog.d/changed-6326-dead-spoke-aliases.md must start with a - bullet; it currently starts with the emoji.
Needed to lift hold
- Retarget the five
src/cmd/hive/*_test.gocall sites tospoke.*(and switch[]hub.AgentSummaryliterals in those tests to[]spoke.AgentSummarywhere the parameter type changes). - Prefix the changelog fragment with
-.
Once that is pushed and lint/test are green I will re-verify and remove hold with lgtm/approved.
Refactor
Cluster claimed:
src/pkg/hub/spoke_deleted_aliases.go+ the 7pkg/hubtest files that referenced its aliases (sso_test.go,heartbeat_activity_test.godeleted;hub_keys_test.go,image_tag_validation_test.go,small_gaps_coverage_test.go,sso_ed25519_coverage_test.go,terminal_key_per_hive_test.goretargeted) andVerifySSOTokenAcrossKeysinhub_pubkey_generations.go. Disjoint from #6292 (config/backends.conf), #6257 (pkg/dashboard/api.go), and #6309 (none of these files in its 218-file diff).What this changes structurally and why
After the spoke extraction (#6068),
pkg/hub/spoke_deleted_aliases.gokept ~21 pass-through aliases.deadcode ./cmd/hiveat v5 tip shows 15 are unreachable from any binary — production callers (pkg/dashboard/session.go,api.go, etc.) already importpkg/hub/spokedirectly. The dead aliases only kept hub-side test copies compiling, several via lossy JSON marshal/unmarshal round-trips between the duplicated hub/spoke struct types (silently dropping drifted fields instead of surfacing them).CollectClusterHealth,OpenFDCount,FDSoftLimit,RolloutRestartSelf,UpgradeSelfToSHApkg/hub/sso_test.go+pkg/hub/heartbeat_activity_test.go— byte-identical duplicates of theirpkg/hub/spoketwins (12 tests ran twice per CI shard)spoke.*VerifySSOTokenAcrossKeysnow callsspoke.VerifySSOTokendirectlyQuotaExhaustedProcessCount/AgentReason,HashDashboardToken,SelfImageReleaseChannel,SelfDeploymentImage,MintSSOToken) with a comment pointing new code atpkg/hub/spokeNo behavior change.
Verification
go build ./...— okgo test ./pkg/hub— ok, coverage 91.3% → 91.4%TestSpokeKeyResolutionAndRotationinpkg/hub/spokefails identically at clean v5 tip because host envHIVE_SSO_PUBLIC_KEYleaks into it — non-hermetic test, beaded separately.Fixes #6326
Filed by architect agent (ACMM L5 — hold-gated mode). Hold-gated: human review required.
— hive: agent=architect backend=copilot model=claude-opus-4-6