fix(internal#248): correct PluginResolver.Resolve return type to SourceResolver
Some checks failed
sop-tier-check / tier-check (pull_request) Failing after 1s
Secret scan / Scan diff for credential-shaped strings (pull_request) Failing after 2s
audit-force-merge / audit (pull_request) Has been skipped

The interface declared Resolve(Source) (PluginResolver, error) but
*Registry.Resolve in source.go:133 returns SourceResolver. Compile-time
assertion `var _ PluginResolver = (*Registry)(nil)` at drift_sweeper.go:82
failed → broke main.go:341 router.Setup and main.go:350 StartPluginDriftSweeper.

Doc comment at drift_sweeper.go:68-69 already stated the intended shape
(returns the production SourceResolver from source.go, not another
PluginResolver) — this aligns the type with the documented contract.

PluginsHandler.WithSourceResolver is unaffected: router.go:545-565
intentionally `_ = pluginResolver`s it out per existing comment.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
Molecule AI · core-be 2026-05-10 12:48:31 +00:00
parent ce23f88edc
commit fce46904ca

View File

@ -61,15 +61,26 @@ const DriftSweepInterval = 1 * time.Hour
// that handles Gitea instances on high-latency links.
const ResolveRefDeadline = 60 * time.Second
// PluginResolver resolves plugin sources to installable directories.
// Satisfied by *Registry (which wraps GithubResolver + LocalResolver).
// PluginResolver is the registry-level abstraction the sweeper consumes:
// pick a per-scheme SourceResolver for a parsed Source, and enumerate the
// registered schemes so we can strip the prefix from a stored source_raw.
//
// Resolve returns the production SourceResolver from source.go (NOT another
// PluginResolver) — that's the actual shape of *Registry.Resolve, and the
// sweeper only needs the per-scheme resolver's identity, not its Fetch.
//
// Named PluginResolver (not SourceResolver) to avoid redeclaring the
// SourceResolver interface defined in source.go (core#228 fix).
// per-scheme SourceResolver interface defined in source.go (core#228 fix).
// Satisfied by *Registry from source.go via Resolve + Schemes.
type PluginResolver interface {
Resolve(source Source) (PluginResolver, error)
Resolve(source Source) (SourceResolver, error)
Schemes() []string
}
// Compile-time assertion: *Registry satisfies PluginResolver. Catches any
// future drift in Registry.Resolve / Schemes signatures at build time.
var _ PluginResolver = (*Registry)(nil)
// StartPluginDriftSweeper runs the drift-detection loop until ctx is cancelled.
// Pass a nil resolver to disable the sweeper (useful for harnesses or CP/SaaS
// mode where git operations are unavailable).