refactor(platform): split 981-line plugins.go into per-domain modules - #11
Merged
Merged
Conversation
Pure mechanical split — no behavior changes. Groups the PluginsHandler
surface area by responsibility so each file stays focused and readable.
Before: plugins.go — 981 lines, 32 funcs
After:
plugins.go — 194 (struct, constructor, shared helpers)
plugins_sources.go — 14 (ListSources)
plugins_listing.go — 174 (ListRegistry, ListInstalled,
ListAvailableForWorkspace,
CheckRuntimeCompatibility)
plugins_install.go — 276 (Install, Uninstall, Download handlers)
plugins_install_pipeline.go — 368 (resolveAndStage, deliverToContainer,
copy/stream tar, CLAUDE.md marker
stripping, dirSize, httpErr,
installRequest/stageResult,
install-layer consts + envx caps)
plugins_test.go (1365 lines) untouched — tests pass unchanged.
go build, go vet, and go test -race ./internal/handlers/... all clean.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
HongmingWang-Rabbit
left a comment
Contributor
Author
There was a problem hiding this comment.
7-Gate Verification — PASSED
- CI — 6/6 green (pre-verified).
- Checkout + build —
go build ./...andgo vet ./...clean on refactor/split-plugins-handler. - Comprehensive tests —
go test -race -count=1 ./...all packages pass (handlers 4.03s fresh, no cache).tests/e2e/test_api.sh= 62/62 pass against live platform. - Security audit — diff grep for
fmt.Sprintfw/ SQL verbs, newos.Getenv(, bearer/CanCommunicate bypass,sk-ant-/ghp_/AKIA,X-Workspace-IDtampering: all clean. Pure code motion, no new env vars, no new auth paths. - Design fit — Go backend refactor; no dialogs/CSS/PM-bypass/doc-link rules apply. Runtime-agnostic plugin filtering logic preserved verbatim in
plugins_listing.go. - Line-level review — function count preserved: original
plugins.gohad 32 funcs; new split isplugins.go(11) +plugins_install.go(3) +plugins_install_pipeline.go(12) +plugins_listing.go(5) +plugins_sources.go(1) = 32.plugins_test.gountouched (0-line diff). Stat: 787 deletions / 832 insertions (delta = package-level doc comments on new files). No behavior change. - Manual UI test — N/A, backend-only refactor.
Pure file-split, no behavior change, no auth/billing/data-deletion surface. Safe to merge via merge-commit.
molecule-ai Bot
pushed a commit
that referenced
this pull request
Apr 21, 2026
refactor(platform): split 981-line plugins.go into per-domain modules
molecule-ai Bot
pushed a commit
that referenced
this pull request
Apr 22, 2026
…ession flagged - PR #1582 (staging-to-main-p0-fix): mergeable=True, 1155 commits, correct exec-form ✅ — add as item #12, recommend as primary path to main - PR #1583: REQUEST_CHANGES review posted — Cmd regression to string concat, same as F1502. Add as item #11. - Update item #3 (superseded by #1582) and #4 (merged) - Update branch HEAD to 034601c - Add PRs row to Affected Systems Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This was referenced Apr 23, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Pure mechanical split of
platform/internal/handlers/plugins.go— no behavior changes, no test changes. Groups thePluginsHandlersurface area by responsibility.Before / after
plugins.goPluginsHandlerstruct, constructor,With*options,RuntimeLookup,pluginInfo+supportsRuntime, manifest parsing (parseManifestYAML,readPluginManifest,strDefault), container helpers (findRunningContainer,execInContainer/execAsRoot/execInContainerAs)plugins_sources.goListSources(GET /plugins/sources)plugins_listing.goListRegistry,listRegistryFiltered,ListAvailableForWorkspace,ListInstalled,CheckRuntimeCompatibilityplugins_install.goInstall,Uninstall,Downloadplugins_install_pipeline.gohttpErr+newHTTPErr,logInstallLimitsOnce,dirSize,validatePluginName,installRequest/stageResult,resolveAndStage,deliverToContainer,copyPluginToContainer,streamDirAsTar,readPluginSkillsFromContainer,stripPluginMarkersFromMemory,regexpEscapeForAwkFunction count preserved: 32 total (was 32 in original
plugins.go).Every file is under the 400-line soft cap;
plugins.gohits the ≤200 target.Judgment calls
validatePluginNameis used by every domain file; parked it inplugins_install_pipeline.go(alongside the other sanitization helpers) rather thanplugins.go, purely to keepplugins.gounder the 200-line target. Same-package, so callers don't care.Install/Uninstall/Downloadstay as full handler bodies inplugins_install.go(not thin wrappers inplugins.go) so the split is mechanical — moving afunc (h *PluginsHandler) Foo()method between files in the same package is a no-op to callers.plugins_sources.gois tiny (14 lines, one handler) but kept as its own file per the grouping requested in the task.Test plan
cd platform && go build ./...— cleango vet ./...— cleango test -race ./internal/handlers/...— passes (cachedok)plugins_test.gountouched (1365 lines, 59 test funcs)plugins*.go🤖 Generated with Claude Code