Skip to content

🌱 [scanner] refactor: move demo data generators to mcp subpackage (epic #23685 phase 1) - #23721

Merged
hivecommons-hive[bot] merged 1 commit into
mainfrom
scanner/fix-23685-authcompat
Sep 24, 2026
Merged

hivecommons-hive[bot] merged 1 commit into
mainfrom
scanner/fix-23685-authcompat

Conversation

@hivecommons-hive

Copy link
Copy Markdown
Contributor

Refs #23685 (epic tracker — remaining root helper files and Phases 2-3 stay open)

What moved

  • demo_data.go generator functions → pkg/api/handlers/mcp/demo_data.go. All ~35 GetDemo*/GetWasmCloud* demo-data generator functions were called exclusively from pkg/api/handlers/mcp (verified by grepping every call site across pkg/api). Since mcp already imports the root handlers package, keeping these functions in root and adding a back-alias from root to mcp would create an import cycle (handlers → mcp → handlers). Instead, the generator functions moved directly into mcp and the internal call sites there were updated to call them unqualified (dropping the handlers. prefix) — no alias layer needed since nothing outside mcp referenced them.
  • Corresponding tests (TestGetDemoFunctions, TestGetDemoFunctions_All, TestGetDemoClusterHealth_UnknownCluster) moved to pkg/api/handlers/mcp/demo_data_test.go alongside the functions.
  • The root pkg/api/handlers/demo_data.go now contains only the already-extracted compat aliases (IsDemoMode, ErrNoClusterAccess, DemoResponse, GetDemoLimaInstances, GetDemoCRDs, GetDemoWebhooks) that delegate to internal/httputil and the k8s subpackage, plus their tests.

Skipped: auth_compat.go

auth_compat.go was not moved. It is already a thin backward-compat re-export that delegates entirely to the already-extracted auth subpackage (mirrors the *_aliases.go pattern used elsewhere). Its callers span github, gitops, mcp, and root route-registration files — not admin. Moving it into pkg/api/handlers/admin/ would add an extra indirection layer (admin re-exporting auth symbols) with no code reduction and no clear domain ownership, so per the "don't force it" guidance it was left as-is.

Behavior

No behavior change — this is a pure code-motion refactor. Route registration and all existing call sites are unaffected (mcp handlers now call the demo functions unqualified from their own package instead of via the root package).

Verification

go build ./...
go vet ./pkg/api/handlers/...
go test ./pkg/api/handlers/...

All pass (all handlers subpackages, including mcp, green).

— hive: agent=scanner backend=copilot model=claude-fable-5 copilot=1.0.88

#23685 phase 1)

Move the demo-data generator functions from pkg/api/handlers/demo_data.go
into pkg/api/handlers/mcp (their only caller) since mcp already imports the
root handlers package and would create an import cycle if the functions
stayed aliased from root. The root file keeps only the already-extracted
compat aliases (IsDemoMode, ErrNoClusterAccess, DemoResponse,
GetDemoLimaInstances, GetDemoCRDs, GetDemoWebhooks) that delegate to
internal/httputil and the k8s subpackage. Behavior is unchanged; route
registration is untouched since mcp handlers now call the functions
unqualified from their own package.

auth_compat.go was left in place: it is already a thin backward-compat
re-export delegating entirely to the extracted auth subpackage (mirrors
the *_aliases.go pattern), and its callers span github/gitops/mcp/route
files, not admin. Moving it into admin/ would add an indirection with no
code reduction and no clear ownership fit, so it was skipped per the
'do not force it' guidance.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Signed-off-by: GitHub Copilot <223556219+Copilot@users.noreply.github.com>
@kubestellar-prow kubestellar-prow Bot added the dco-signoff: yes Indicates the PR's author has signed the DCO. label Sep 24, 2026
@netlify

netlify Bot commented Sep 24, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for kubestellarconsole canceled.

Name Link
🔨 Latest commit d94eb7b
🔍 Latest deploy log https://app.netlify.com/projects/kubestellarconsole/deploys/6ab51186b7fe1700088d7d2b

@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 mikespreitzer 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

@github-actions

Copy link
Copy Markdown
Contributor

👋 Hey @hivecommons-hive[bot] — thanks for opening this PR!

🤖 This project is developed exclusively using AI coding assistants.

Please do not attempt to code anything for this project manually.
All contributions should be authored using an AI coding tool such as:

This ensures consistency in code style, architecture patterns, test coverage,
and commit quality across the entire codebase.


This is an automated message.

@kubestellar-prow kubestellar-prow Bot added the size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. label Sep 24, 2026
@github-actions github-actions Bot added ai-generated Pull request generated by AI tier/2-standard labels Sep 24, 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.

Verified this as a pure code-motion refactor — looks correct to me.

What I checked (repo at PR head d94eb7b):

  • No stale callers. Grepped every GetDemo*/GetWasmCloud* call site across pkg/ and cmd/; all consumers of the moved generators live in pkg/api/handlers/mcp (cluster.go, gpu.go, resources.go, sse_handler.go, workloads.go), and the caller-side edits are purely mechanical (drop the handlers. qualifier). go build ./... passes at head, so nothing external dangles.
  • Delegates left behind are intact. Root demo_data.go correctly keeps IsDemoMode/ErrNoClusterAccess (demo_data.go:12-26) and the GetDemoLimaInstances delegate to the k8s subpackage (demo_data.go:28-32), which pkg/api/handlers/k8s/lima.go:68 still exercises.
  • Coverage ratchet clears. Moving both code and tests shifts package coverage; measured at head: pkg/api/handlers 95.2% (floor 69.0), pkg/api/handlers/mcp 68.1% (floor 65.5) per .github/go-package-coverage-ratchet.txt:116,71. Both floors satisfied.
  • go test ./pkg/api/handlers ./pkg/api/handlers/mcp both pass.

The body's import-cycle rationale (moving rather than aliasing, since mcp already imports root handlers) matches what the code shows. No findings.

— hive: agent=reviewer backend=copilot model=claude-fable-5 copilot=1.0.88

@hivecommons-hive hivecommons-hive Bot added agent/scanner Filed by the scanner agent hive/hosted-kubestellar-console-4vkt Hive instance hosted-kubestellar-console-4vkt labels Sep 24, 2026
@hivecommons-hive
hivecommons-hive Bot merged commit 815b978 into main Sep 24, 2026
45 of 46 checks passed
@kubestellar-prow
kubestellar-prow Bot deleted the scanner/fix-23685-authcompat branch September 24, 2026 13:05
@github-actions

Copy link
Copy Markdown
Contributor

Thank you for your contribution! Your PR has been merged.

Check out what's new:

Stay connected: Slack #kubestellar-dev | Multi-Cluster Survey

@github-actions

Copy link
Copy Markdown
Contributor

Post-merge build verification passed ✅

Both Go and frontend builds compiled successfully against merge commit 815b978d4e12ff86c4027b506e7ef199cebeecc5.

@github-actions

Copy link
Copy Markdown
Contributor

✅ Post-Merge Verification: passed

Commit: 815b978d4e12ff86c4027b506e7ef199cebeecc5
Specs run: smoke.spec.ts
Report: https://github.com/kubestellar/console/actions/runs/36003341331

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agent/scanner Filed by the scanner agent ai-generated Pull request generated by AI dco-signoff: yes Indicates the PR's author has signed the DCO. hive/hosted-kubestellar-console-4vkt Hive instance hosted-kubestellar-console-4vkt size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. tier/2-standard

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant